2024-01-15 19:26:08 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
|
|
using UnityEngine;
|
2024-01-15 20:25:49 +08:00
|
|
|
|
using UnityEngine.Serialization;
|
2024-01-15 19:26:08 +08:00
|
|
|
|
|
2024-02-22 14:33:40 +08:00
|
|
|
|
public enum PostProcessTextureUnitSize
|
|
|
|
|
|
{
|
|
|
|
|
|
_256 = 256,
|
|
|
|
|
|
_512 = 512,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-15 19:26:08 +08:00
|
|
|
|
public class PostProcessInstructor : MonoBehaviour
|
|
|
|
|
|
{
|
2024-01-17 13:44:26 +08:00
|
|
|
|
[FormerlySerializedAs("combinedRoots")]
|
|
|
|
|
|
[LabelText("需要网格合并节点")]
|
2024-01-15 19:26:08 +08:00
|
|
|
|
[ListDrawerSettings(AlwaysAddDefaultValue = false)]
|
2024-01-17 13:44:26 +08:00
|
|
|
|
public List<Transform> rootsToCombine = new();
|
2024-01-15 19:26:08 +08:00
|
|
|
|
|
2024-01-17 13:44:26 +08:00
|
|
|
|
[FormerlySerializedAs("art")]
|
|
|
|
|
|
[LabelText("网格合并后父节点")]
|
|
|
|
|
|
public Transform combinedObjectsRoot;
|
2024-01-15 19:26:08 +08:00
|
|
|
|
|
|
|
|
|
|
[LabelText("地面")]
|
2024-01-16 14:23:05 +08:00
|
|
|
|
public GameObject ground;
|
2024-01-15 19:26:08 +08:00
|
|
|
|
|
|
|
|
|
|
[LabelText("雾")]
|
2024-01-16 14:23:05 +08:00
|
|
|
|
public GameObject fog;
|
2024-01-15 19:26:08 +08:00
|
|
|
|
|
|
|
|
|
|
[LabelText("后处理预制体")]
|
|
|
|
|
|
public bool processPrefab;
|
2024-02-22 14:33:40 +08:00
|
|
|
|
|
|
|
|
|
|
[LabelText("单位贴图尺寸")]
|
|
|
|
|
|
public PostProcessTextureUnitSize postProcessTextureUnitSize = PostProcessTextureUnitSize._256;
|
2024-12-13 15:06:43 +08:00
|
|
|
|
|
|
|
|
|
|
[LabelText("后处理指定材质")]
|
|
|
|
|
|
public List<Material> sampleMaterials = new();
|
2025-04-01 16:59:45 +08:00
|
|
|
|
|
|
|
|
|
|
[LabelText("启用分组合批")]
|
|
|
|
|
|
[Tooltip("启用分组合批可以减少单次渲染的对象数量,但会增加DrawCall")]
|
2025-05-14 16:59:53 +08:00
|
|
|
|
public bool enableBatchGrouping = true;
|
2025-04-01 16:59:45 +08:00
|
|
|
|
|
|
|
|
|
|
[LabelText("分组合批距离")]
|
|
|
|
|
|
[Tooltip("物体之间的距离超过此值将被分到不同组,距离越大分组越少;距离越小分组越多")]
|
|
|
|
|
|
[Range(2.0f, 50.0f)]
|
2025-05-14 16:59:53 +08:00
|
|
|
|
public float batchGroupDistance = 5.0f;
|
2025-04-07 18:55:27 +08:00
|
|
|
|
|
|
|
|
|
|
[Header("灯光烘焙设置")]
|
|
|
|
|
|
[LabelText("启用灯光烘焙")]
|
|
|
|
|
|
[Tooltip("启用后将在合批完成后进行灯光烘焙")]
|
2025-05-14 16:59:53 +08:00
|
|
|
|
public bool enableLightmapBaking = true;
|
2025-05-08 11:59:40 +08:00
|
|
|
|
|
|
|
|
|
|
// 暂时禁用关闭切割功能
|
|
|
|
|
|
[Header("切割地面")]
|
|
|
|
|
|
[LabelText("启用切割地面")]
|
|
|
|
|
|
[Tooltip("启用后将在合批完成后进行地面切割")]
|
|
|
|
|
|
[HideInInspector]
|
|
|
|
|
|
public bool enableSplitGround = false;
|
2025-04-07 14:18:07 +08:00
|
|
|
|
|
|
|
|
|
|
[Header("模型切割设置")]
|
|
|
|
|
|
[LabelText("启用模型切割")]
|
|
|
|
|
|
[Tooltip("启用后会在模型合并前进行切割处理,裁切地面以下的模型部分")]
|
|
|
|
|
|
public bool enableModelSlicing = false;
|
|
|
|
|
|
|
|
|
|
|
|
[LabelText("需要切割的模型节点")]
|
|
|
|
|
|
[ListDrawerSettings(AlwaysAddDefaultValue = false), ShowIf("enableModelSlicing")]
|
|
|
|
|
|
[Tooltip("选择需要进行切割的模型父节点,不在此列表中的模型不会被切割")]
|
|
|
|
|
|
public List<Transform> rootsToSlice = new();
|
|
|
|
|
|
|
|
|
|
|
|
[LabelText("切割面材质")]
|
|
|
|
|
|
[Tooltip("切割面使用的材质,需要一个简单的不透明材质,暂时不使用新材质"), ShowIf("enableModelSlicing"), HideInInspector]
|
|
|
|
|
|
public Material sliceMaterial;
|
|
|
|
|
|
|
|
|
|
|
|
[LabelText("切割平面方向")]
|
|
|
|
|
|
[Tooltip("切割平面的法线方向,默认使用地面的上方向,暂时固定不用改变"), HideInInspector]
|
|
|
|
|
|
public Vector3 slicePlaneDirection = Vector3.up;
|
|
|
|
|
|
|
|
|
|
|
|
[LabelText("忽略边界检测")]
|
|
|
|
|
|
[Tooltip("启用后将忽略边界检测直接进行切割,解决一些边界检测不准确的问题"), ShowIf("enableModelSlicing"), HideInInspector]
|
|
|
|
|
|
public bool ignoreObjectBoundsCheck = false;
|
|
|
|
|
|
|
|
|
|
|
|
[LabelText("异步切割")]
|
|
|
|
|
|
[Tooltip("启用异步处理可以提高性能,但可能在某些情况下导致问题,暂时禁用"), HideInInspector]
|
|
|
|
|
|
public bool sliceAsynchronously = false;
|
|
|
|
|
|
|
|
|
|
|
|
[LabelText("保留原始模型")]
|
|
|
|
|
|
[Tooltip("启用后将在切割完成后保留原始未切割的模型,便于对比或调试"), ShowIf("enableModelSlicing")]
|
|
|
|
|
|
public bool preserveOriginalModels = false;
|
|
|
|
|
|
|
|
|
|
|
|
// 保存网格资源,暂时禁用
|
|
|
|
|
|
[LabelText("保存切割后的网格")]
|
|
|
|
|
|
[Tooltip("启用后将切割后的网格保存到Assets目录,便于后续使用,暂时禁用"), ShowIf("enableModelSlicing"), HideInInspector]
|
|
|
|
|
|
public bool saveMeshesToAssets = false;
|
|
|
|
|
|
|
|
|
|
|
|
[LabelText("网格保存路径")]
|
|
|
|
|
|
[Tooltip("切割后网格保存的路径,相对于Assets目录,暂时禁用"), ShowIf("@this.enableModelSlicing && this.saveMeshesToAssets"), HideInInspector]
|
|
|
|
|
|
public string meshSavePath = "SlicedMeshes";
|
|
|
|
|
|
|
|
|
|
|
|
[LabelText("添加时间戳")]
|
|
|
|
|
|
[Tooltip("为保存的网格添加时间戳,避免名称冲突,暂时禁用"), ShowIf("@this.enableModelSlicing && this.saveMeshesToAssets"), HideInInspector]
|
|
|
|
|
|
public bool addTimestampToMeshName = true;
|
2024-01-15 19:26:08 +08:00
|
|
|
|
}
|