diff --git a/Assets/Res/Main/Scene/LightTest.unity b/Assets/Res/Main/Scene/LightTest.unity index 8249887..71fdcf2 100644 --- a/Assets/Res/Main/Scene/LightTest.unity +++ b/Assets/Res/Main/Scene/LightTest.unity @@ -122,78 +122,6 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!1 &6388584 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 6388586} - - component: {fileID: 6388585} - - component: {fileID: 6388587} - m_Layer: 0 - m_Name: ShadowColliderSystem - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &6388585 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6388584} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 836b4625937ba9d45be59618cd2a6a15, type: 3} - m_Name: - m_EditorClassIdentifier: - shadowLight: {fileID: 354864581} - shadowWall: {fileID: 1371778128} - shadowLayerName: Shadow - obstacleLayerMask: - serializedVersion: 2 - m_Bits: 1024 - generateOnStart: 1 - updateInRealTime: 0 - updateInterval: 0.1 - shadowColliders: [] ---- !u!4 &6388586 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6388584} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &6388587 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6388584} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 7911d7cd239cfb44c910a896590b2db4, type: 3} - m_Name: - m_EditorClassIdentifier: - shadowLight: {fileID: 354864581} - shadowWall: {fileID: 1371778128} - shadowLayerName: Shadow - keepOriginalMesh: 1 - shadowIntensity: 1 --- !u!1 &282165411 GameObject: m_ObjectHideFlags: 0 @@ -440,7 +368,7 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: -7.901, y: 3.191, z: 0} ---- !u!1 &488143178 +--- !u!1 &911800373 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -448,10 +376,10 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 488143182} - - component: {fileID: 488143181} - - component: {fileID: 488143180} - - component: {fileID: 488143179} + - component: {fileID: 911800377} + - component: {fileID: 911800376} + - component: {fileID: 911800375} + - component: {fileID: 911800374} m_Layer: 0 m_Name: MainCamera m_TagString: MainCamera @@ -459,13 +387,13 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &488143179 +--- !u!114 &911800374 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 488143178} + m_GameObject: {fileID: 911800373} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} @@ -503,21 +431,21 @@ MonoBehaviour: m_MipBias: 0 m_VarianceClampScale: 0.9 m_ContrastAdaptiveSharpening: 0 ---- !u!81 &488143180 +--- !u!81 &911800375 AudioListener: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 488143178} + m_GameObject: {fileID: 911800373} m_Enabled: 1 ---- !u!20 &488143181 +--- !u!20 &911800376 Camera: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 488143178} + m_GameObject: {fileID: 911800373} m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 1 @@ -562,13 +490,13 @@ Camera: m_OcclusionCulling: 1 m_StereoConvergence: 10 m_StereoSeparation: 0.022 ---- !u!4 &488143182 +--- !u!4 &911800377 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 488143178} + m_GameObject: {fileID: 911800373} serializedVersion: 2 m_LocalRotation: {x: 0.102426775, y: -0.0044816174, z: 0.0004422885, w: 0.9947304} m_LocalPosition: {x: 0.582394, y: 6.9680796, z: -1.88675} @@ -577,369 +505,6 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &507957216 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 507957221} - - component: {fileID: 507957220} - - component: {fileID: 507957219} - - component: {fileID: 507957218} - - component: {fileID: 507957217} - m_Layer: 9 - m_Name: Cube (2) - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &507957217 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 507957216} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 717ba394b4fc8354db9479f2f858d521, type: 3} - m_Name: - m_EditorClassIdentifier: - mainCamera: {fileID: 0} - model3D: {fileID: 507957216} - edgeSegments: 16 ---- !u!65 &507957218 -BoxCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 507957216} - m_Material: {fileID: 0} - m_IncludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ExcludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_LayerOverridePriority: 0 - m_IsTrigger: 0 - m_ProvidesContacts: 0 - m_Enabled: 1 - serializedVersion: 3 - m_Size: {x: 1, y: 1, z: 1} - m_Center: {x: 0, y: 0, z: 0} ---- !u!23 &507957219 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 507957216} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 2 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_AdditionalVertexStreams: {fileID: 0} ---- !u!33 &507957220 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 507957216} - m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &507957221 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 507957216} - serializedVersion: 2 - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0.54599994, y: 5.58, z: 2.41} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &767553978 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 767553982} - - component: {fileID: 767553981} - - component: {fileID: 767553980} - - component: {fileID: 767553983} - - component: {fileID: 767553985} - m_Layer: 0 - m_Name: Plane - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!23 &767553980 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 767553978} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 2 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 4918217319983852589, guid: 9d45be5b270ce92469f786691135214c, type: 3} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_AdditionalVertexStreams: {fileID: 0} ---- !u!33 &767553981 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 767553978} - m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &767553982 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 767553978} - serializedVersion: 2 - m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068} - m_LocalPosition: {x: 0, y: 5, z: 5} - m_LocalScale: {x: 2, y: 2, z: 2} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0} ---- !u!114 &767553983 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 767553978} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 28f43899f7559ca4e915497eaf23cc4f, type: 3} - m_Name: - m_EditorClassIdentifier: - shadowCamera: {fileID: 282165414} - shadowRT: {fileID: 8400000, guid: 3746a9ea25b5f084f963f36250ae89a2, type: 2} - polygonCollider: {fileID: 0} - shadowThreshold: 0.3 - gridSize: 2 - simplifyTolerance: 2 ---- !u!65 &767553985 -BoxCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 767553978} - m_Material: {fileID: 0} - m_IncludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ExcludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_LayerOverridePriority: 0 - m_IsTrigger: 0 - m_ProvidesContacts: 0 - m_Enabled: 1 - serializedVersion: 3 - m_Size: {x: 10, y: 1.2295777, z: 10.000002} - m_Center: {x: 0, y: -0.61478895, z: 1.6312508e-15} ---- !u!1 &1283729761 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1283729764} - - component: {fileID: 1283729763} - - component: {fileID: 1283729762} - m_Layer: 0 - m_Name: Directional Light - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1283729762 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1283729761} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Version: 3 - m_UsePipelineSettings: 1 - m_AdditionalLightsShadowResolutionTier: 2 - m_LightLayerMask: 1 - m_RenderingLayers: 1 - m_CustomShadowLayers: 0 - m_ShadowLayerMask: 1 - m_ShadowRenderingLayers: 1 - m_LightCookieSize: {x: 1, y: 1} - m_LightCookieOffset: {x: 0, y: 0} - m_SoftShadowQuality: 0 ---- !u!108 &1283729763 -Light: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1283729761} - m_Enabled: 1 - serializedVersion: 10 - m_Type: 1 - m_Shape: 0 - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_Intensity: 0.1 - m_Range: 10 - m_SpotAngle: 30 - m_InnerSpotAngle: 21.80208 - m_CookieSize: 10 - m_Shadows: - m_Type: 0 - m_Resolution: -1 - m_CustomResolution: -1 - m_Strength: 1 - m_Bias: 0.05 - m_NormalBias: 0.4 - m_NearPlane: 0.2 - m_CullingMatrixOverride: - e00: 1 - e01: 0 - e02: 0 - e03: 0 - e10: 0 - e11: 1 - e12: 0 - e13: 0 - e20: 0 - e21: 0 - e22: 1 - e23: 0 - e30: 0 - e31: 0 - e32: 0 - e33: 1 - m_UseCullingMatrixOverride: 0 - m_Cookie: {fileID: 0} - m_DrawHalo: 0 - m_Flare: {fileID: 0} - m_RenderMode: 0 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingLayerMask: 1 - m_Lightmapping: 4 - m_LightShadowCasterMode: 0 - m_AreaSize: {x: 1, y: 1} - m_BounceIntensity: 1 - m_ColorTemperature: 6570 - m_UseColorTemperature: 0 - m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} - m_UseBoundingSphereOverride: 0 - m_UseViewFrustumForShadowCasterCull: 1 - m_ShadowRadius: 0 - m_ShadowAngle: 0 ---- !u!4 &1283729764 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1283729761} - serializedVersion: 2 - m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} - m_LocalPosition: {x: 3.5268085, y: -6.844941, z: 52.119446} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!1 &1371778123 GameObject: m_ObjectHideFlags: 0 @@ -952,39 +517,13 @@ GameObject: - component: {fileID: 1371778127} - component: {fileID: 1371778126} - component: {fileID: 1371778125} - - component: {fileID: 1371778130} - - component: {fileID: 1371778129} - - component: {fileID: 1371778124} - - component: {fileID: 1371778131} m_Layer: 10 - m_Name: Cube + m_Name: Panel m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!114 &1371778124 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1371778123} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 21f7e71103c1a5941af3223174264656, type: 3} - m_Name: - m_EditorClassIdentifier: - spotLight: {fileID: 354864581} - shadowCasters: [] - shadowCasterLayer: - serializedVersion: 2 - m_Bits: 0 - shadowReceiverLayer: - serializedVersion: 2 - m_Bits: 0 - maxShadowDistance: 10 - shadowCollider: {fileID: 1974410756} --- !u!65 &1371778125 BoxCollider: m_ObjectHideFlags: 0 @@ -1073,61 +612,6 @@ Transform: - {fileID: 1835604431} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1371778129 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1371778123} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 28f43899f7559ca4e915497eaf23cc4f, type: 3} - m_Name: - m_EditorClassIdentifier: - shadowCamera: {fileID: 282165414} - shadowRT: {fileID: 8400000, guid: 3746a9ea25b5f084f963f36250ae89a2, type: 2} - polygonCollider: {fileID: 1974410756} - shadowThreshold: 0 - gridSize: 2 - simplifyTolerance: 0.1 ---- !u!114 &1371778130 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1371778123} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 7b369cd814f44044d8a55791d065e3fb, type: 3} - m_Name: - m_EditorClassIdentifier: - shadowCamera: {fileID: 282165414} - shadowRT: {fileID: 8400000, guid: 3746a9ea25b5f084f963f36250ae89a2, type: 2} - polygonCollider: {fileID: 1974410756} - shadowThreshold: 0.1 - gridResolution: 64 - minContourArea: 10 - maxGapDistance: 20 ---- !u!114 &1371778131 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1371778123} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: eb1369db1529b6543ba24519d5c2a35d, type: 3} - m_Name: - m_EditorClassIdentifier: - shadowCamera: {fileID: 282165414} - shadowRT: {fileID: 8400000, guid: 3746a9ea25b5f084f963f36250ae89a2, type: 2} - polygonCollider: {fileID: 1974410756} - shadowThreshold: 0.1 - downSample: 4 - minShadowSize: 0.1 --- !u!1 &1455178660 GameObject: m_ObjectHideFlags: 0 @@ -1140,7 +624,6 @@ GameObject: - component: {fileID: 1455178663} - component: {fileID: 1455178662} - component: {fileID: 1455178661} - - component: {fileID: 1455178665} m_Layer: 9 m_Name: Cube m_TagString: Untagged @@ -1234,21 +717,6 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1455178665 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1455178660} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 717ba394b4fc8354db9479f2f858d521, type: 3} - m_Name: - m_EditorClassIdentifier: - mainCamera: {fileID: 0} - model3D: {fileID: 1455178660} - edgeSegments: 16 --- !u!1 &1835604430 GameObject: m_ObjectHideFlags: 0 @@ -1475,16 +943,62 @@ PolygonCollider2D: m_Paths: - [] m_UseDelaunayMesh: 0 +--- !u!1 &2043251345 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2043251347} + - component: {fileID: 2043251346} + m_Layer: 0 + m_Name: ShadowColloderGenerator + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &2043251346 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2043251345} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 28f43899f7559ca4e915497eaf23cc4f, type: 3} + m_Name: + m_EditorClassIdentifier: + shadowCamera: {fileID: 282165414} + shadowRT: {fileID: 8400000, guid: 3746a9ea25b5f084f963f36250ae89a2, type: 2} + shadowThreshold: 0.3 + gridSize: 2 + simplifyTolerance: 1 +--- !u!4 &2043251347 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2043251345} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 m_Roots: - {fileID: 354864582} - {fileID: 1371778128} - - {fileID: 767553982} - - {fileID: 488143182} - - {fileID: 1283729764} - {fileID: 282165415} - {fileID: 1455178664} - - {fileID: 507957221} - - {fileID: 6388586} + - {fileID: 2043251347} + - {fileID: 911800377} diff --git a/Assets/Scripts/Test/Light/ShadowCapture.cs b/Assets/Scripts/Test/Light/ShadowCapture.cs new file mode 100644 index 0000000..ceed350 --- /dev/null +++ b/Assets/Scripts/Test/Light/ShadowCapture.cs @@ -0,0 +1,47 @@ +// ShadowCapture.cs +using UnityEngine; +using UnityEngine.Rendering; + +public class ShadowCapture : MonoBehaviour +{ + public Light mainLight; + public Camera shadowCamera; + public RenderTexture shadowTexture; + + private CommandBuffer commandBuffer; + + void Start() + { + commandBuffer = new CommandBuffer(); + commandBuffer.name = "Shadow Capture"; + + //// 创建Render Texture + //shadowTexture = new RenderTexture(1024, 1024, 0, RenderTextureFormat.ARGB32); + //shadowTexture.name = "Shadow Map"; + + // 设置Command Buffer + commandBuffer.SetRenderTarget(shadowTexture); + commandBuffer.ClearRenderTarget(true, true, Color.clear); + + // 只渲染特定层的物体 + commandBuffer.SetGlobalColor("_ShadowColor", Color.black); + + // 添加到相机 + shadowCamera.AddCommandBuffer(CameraEvent.BeforeForwardOpaque, commandBuffer); + } + + void Update() + { + // 更新阴影纹理到Shader + Shader.SetGlobalTexture("_CustomShadowMap", shadowTexture); + } + + void OnDestroy() + { + if (commandBuffer != null) + { + shadowCamera.RemoveCommandBuffer(CameraEvent.BeforeForwardOpaque, commandBuffer); + commandBuffer.Dispose(); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Test/Light/ShadowCapture.cs.meta b/Assets/Scripts/Test/Light/ShadowCapture.cs.meta new file mode 100644 index 0000000..6af4a96 --- /dev/null +++ b/Assets/Scripts/Test/Light/ShadowCapture.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 91b16d90959a0334da9eaebad7c79995 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Test/Light/ShadowColliderGenerator.cs b/Assets/Scripts/Test/Light/ShadowColliderGenerator.cs index e17c21b..6d1373b 100644 --- a/Assets/Scripts/Test/Light/ShadowColliderGenerator.cs +++ b/Assets/Scripts/Test/Light/ShadowColliderGenerator.cs @@ -4,14 +4,11 @@ using System.Linq; public class ShadowColliderGenerator : MonoBehaviour { - [Header("References")] public Camera shadowCamera; public RenderTexture shadowRT; - public PolygonCollider2D polygonCollider; - [Header("Settings")] [Range(0f, 1f)] - public float shadowThreshold = 0.3f; + public float shadowThreshold = 0.1f; public int gridSize = 2; // 缃戞牸澶у皬锛岃秺灏忚秺绮剧‘ public float simplifyTolerance = 1f; @@ -19,9 +16,6 @@ public class ShadowColliderGenerator : MonoBehaviour void Start() { - if (polygonCollider == null) - polygonCollider = GetComponent(); - processedTexture = new Texture2D(shadowRT.width, shadowRT.height, TextureFormat.R8, false); GenerateCollider(); } @@ -36,253 +30,411 @@ public class ShadowColliderGenerator : MonoBehaviour [ContextMenu("Generate Collider")] public void GenerateCollider() + { + + ReadRenderTexture(); + + } + void ReadRenderTexture() { if (shadowCamera == null || shadowRT == null) return; - - // 娓叉煋闃村奖 shadowCamera.Render(); - - // 璇诲彇绾圭悊 RenderTexture.active = shadowRT; processedTexture.ReadPixels(new Rect(0, 0, shadowRT.width, shadowRT.height), 0, 0); processedTexture.Apply(); RenderTexture.active = null; - - // 鐢熸垚杞粨 - List contour = GenerateContourFromTexture(); - - if (contour.Count > 2) + Color[] pixels = processedTexture.GetPixels(); + float[,] grid = new float[shadowRT.width, shadowRT.height]; + for (int y = 0; y < shadowRT.height; y++) { - List worldPoints = ConvertToWorldCoordinates(contour); - polygonCollider.SetPath(0, worldPoints); - Debug.Log($"Collider generated with {worldPoints.Count} points"); - } - else - { - polygonCollider.pathCount = 0; - Debug.Log("No contour generated"); - } - } - - List GenerateContourFromTexture() - { - int width = processedTexture.width; - int height = processedTexture.height; - - // 鍒涘缓浜屽煎寲缃戞牸 - bool[,] grid = CreateBinaryGrid(width, height); - - // 鎵惧埌鎵鏈夎竟鐣岀偣 - List boundaryPoints = FindBoundaryPoints(grid); - - // 杩炴帴杈圭晫鐐瑰舰鎴愯疆寤 - List contour = ConnectBoundaryPoints(boundaryPoints); - - return contour; - } - - bool[,] CreateBinaryGrid(int width, int height) - { - bool[,] grid = new bool[width / gridSize, height / gridSize]; - - for (int x = 0; x < grid.GetLength(0); x++) - { - for (int y = 0; y < grid.GetLength(1); y++) + for (int x = 0; x < shadowRT.width; x++) { - int texX = x * gridSize; - int texY = y * gridSize; - Color pixel = processedTexture.GetPixel(texX, texY); - grid[x, y] = pixel.grayscale < shadowThreshold; + // 鍙彇R閫氶亾锛堝洜涓烘槸鐏板害鍥撅紝RGB鍊肩浉鍚岋級 + grid[x, y] = pixels[y * shadowRT.width + x].r; } } - return grid; + Debug.Log($"{grid[0, shadowRT.height - 1]:F3}, {grid[shadowRT.width - 1, 0]:F3}"); + AnalyzeWithMarchingSquares(grid, shadowThreshold); } - - List FindBoundaryPoints(bool[,] grid) + void AnalyzeWithMarchingSquares(float[,] grid, float checkValue) { - List boundaryPoints = new List(); + //List allEdgePoints = CollectAllEdgePoints(grid, checkValue); + //List contour = ImprovedContourConnection(allEdgePoints); + //UpdatePolygonCollider(allEdgePoints, grid.GetLength(0), grid.GetLength(1)); + + //Debug.Log("Marching Squares澶勭悊瀹屾垚"); + + // 浣跨敤姝g‘鐨勮疆寤撹窡韪 int width = grid.GetLength(0); int height = grid.GetLength(1); - for (int x = 0; x < width; x++) + // 浣跨敤姝g‘鐨勮疆寤撹窡韪 + List> contours = GenerateContours(grid, checkValue, width, height); + + // 杩囨护鎺夌偣澶皯鐨勮疆寤 + List> validContours = contours; + //List> validContours = contours.Where(c => c.Count > 10).ToList(); + + Debug.Log($"鐢熸垚 {contours.Count} 涓疆寤擄紝鏈夋晥杞粨 {validContours.Count} 涓"); + + // 鏄剧ず姣忎釜杞粨鐨勪俊鎭 + for (int i = 0; i < Mathf.Min(5, validContours.Count); i++) // 鍙樉绀哄墠5涓 { - for (int y = 0; y < height; y++) - { - if (grid[x, y]) - { - // 妫鏌ユ槸鍚︽槸杈圭晫锛堟湁闈為槾褰卞儚绱犻偦灞咃級 - bool isBoundary = false; - - // 妫鏌4閭诲煙 - if (x == 0 || !grid[x - 1, y]) isBoundary = true; - else if (x == width - 1 || !grid[x + 1, y]) isBoundary = true; - else if (y == 0 || !grid[x, y - 1]) isBoundary = true; - else if (y == height - 1 || !grid[x, y + 1]) isBoundary = true; - - if (isBoundary) - { - boundaryPoints.Add(new Vector2(x * gridSize, y * gridSize)); - } - } - } + Debug.Log($"杞粨 {i}: {validContours[i].Count} 涓偣"); } - Debug.Log($"Found {boundaryPoints.Count} boundary points"); - return boundaryPoints; + // 浣跨敤鎵鏈夋湁鏁堣疆寤撳垱寤虹鎾炰綋 + UpdatePolygonCollider(validContours, width, height); + + Debug.Log("Marching Squares澶勭悊瀹屾垚"); } - List ConnectBoundaryPoints(List points) - { - if (points.Count < 3) return points; - - List contour = new List(); - List remaining = new List(points); - - // 鎵惧埌鏈宸﹁竟鐨勭偣浣滀负璧风偣 - Vector2 start = remaining.OrderBy(p => p.x).First(); - contour.Add(start); - remaining.Remove(start); - - Vector2 current = start; - Vector2 previousDirection = Vector2.right; - - int maxIterations = points.Count * 2; - int iterations = 0; - - while (remaining.Count > 0 && iterations < maxIterations) - { - iterations++; - - // 鎵惧埌涓庡綋鍓嶆柟鍚戞渶涓鑷寸殑涓嬩竴涓偣 - float bestScore = float.MinValue; - Vector2 bestPoint = Vector2.zero; - int bestIndex = -1; - - for (int i = 0; i < remaining.Count; i++) - { - Vector2 toPoint = (remaining[i] - current).normalized; - float distance = Vector2.Distance(current, remaining[i]); - - // 璇勫垎锛氭柟鍚戜竴鑷存 + 璺濈鏉冮噸 - float directionScore = Vector2.Dot(previousDirection, toPoint); - float distanceScore = 1f / (distance + 0.1f); - float totalScore = directionScore + distanceScore * 0.1f; - - if (totalScore > bestScore && distance < 50f) // 璺濈闄愬埗 - { - bestScore = totalScore; - bestPoint = remaining[i]; - bestIndex = i; - } - } - - if (bestIndex >= 0) - { - previousDirection = (bestPoint - current).normalized; - contour.Add(bestPoint); - remaining.RemoveAt(bestIndex); - current = bestPoint; - } - else - { - break; - } - } - - // 纭繚杞粨闂悎 - if (contour.Count > 2 && Vector2.Distance(contour[0], contour[contour.Count - 1]) > 30f) - { - contour.Add(contour[0]); - } - - // 绠鍖栬疆寤 - contour = SimplifyContour(contour); - - Debug.Log($"Connected {contour.Count} points into contour"); - return contour; - } - - List SimplifyContour(List contour) - { - if (contour.Count <= 3) return contour; - - List simplified = new List(); - simplified.Add(contour[0]); - - for (int i = 1; i < contour.Count - 1; i++) - { - // 濡傛灉瑙掑害鍙樺寲澶ぇ锛屼繚鐣欒繖涓偣 - if (i > 1) - { - Vector2 prevDir = (contour[i] - contour[i - 1]).normalized; - Vector2 nextDir = (contour[i + 1] - contour[i]).normalized; - float angle = Vector2.Angle(prevDir, nextDir); - - if (angle > 30f) // 瑙掑害闃堝 - { - simplified.Add(contour[i]); - } - } - } - - simplified.Add(contour[contour.Count - 1]); - - return simplified; - } - - List ConvertToWorldCoordinates(List texturePoints) + List ConvertToWorldCoordinates(List texturePoints, int textureWidth, int textureHeight) { List worldPoints = new List(); foreach (Vector2 texCoord in texturePoints) { - Vector3 viewportPos = new Vector3( - texCoord.x / processedTexture.width, - texCoord.y / processedTexture.height, - shadowCamera.nearClipPlane + // 灏嗙汗鐞嗗潗鏍囧綊涓鍖栧埌 [0,1] 鑼冨洿 + Vector2 normalizedCoord = new Vector2( + texCoord.x / textureWidth, + texCoord.y / textureHeight ); - Vector3 worldPos = shadowCamera.ViewportToWorldPoint(viewportPos); - worldPoints.Add(new Vector2(worldPos.x, worldPos.y)); + // 灏嗗綊涓鍖栧潗鏍囪浆鎹㈠埌涓栫晫鍧愭爣 + // 鍋囪澧欑殑鏈湴鍧愭爣鑼冨洿鏄 [0,0] 鍒 [1,1] + Vector2 worldPoint = normalizedCoord; + + worldPoints.Add(worldPoint); } return worldPoints; } - // 璋冭瘯锛氭樉绀鸿竟鐣岀偣 - void OnDrawGizmosSelected() + /// + /// 鍒涘缓鎴栨洿鏂癙olygonCollider2D锛堟敮鎸佸涓疆寤擄級 + /// + void UpdatePolygonCollider(List> contours, int textureWidth, int textureHeight) { - if (processedTexture == null) return; - - Gizmos.color = Color.red; - - // 鏄剧ず杈圭晫鐐 - bool[,] grid = CreateBinaryGrid(processedTexture.width, processedTexture.height); - List boundaryPoints = FindBoundaryPoints(grid); - - foreach (Vector2 point in boundaryPoints) + // 鑾峰彇鎴栨坊鍔燩olygonCollider2D缁勪欢 + PolygonCollider2D polygonCollider = GetComponent(); + if (polygonCollider == null) { - Vector3 viewportPos = new Vector3( - point.x / processedTexture.width, - point.y / processedTexture.height, - shadowCamera.nearClipPlane - ); - Vector3 worldPos = shadowCamera.ViewportToWorldPoint(viewportPos); - Gizmos.DrawSphere(worldPos, 0.02f); + polygonCollider = gameObject.AddComponent(); + Debug.Log("娣诲姞PolygonCollider2D缁勪欢"); } - // 鏄剧ず纰版挒鍣ㄨ疆寤 - if (polygonCollider != null && polygonCollider.pathCount > 0) + if (contours.Count > 0) { - Gizmos.color = Color.green; - Vector2[] path = polygonCollider.GetPath(0); - for (int i = 0; i < path.Length; i++) + // 璁剧疆杞粨鏁伴噺 + polygonCollider.pathCount = contours.Count; + + int totalPoints = 0; + + for (int i = 0; i < contours.Count; i++) { - Vector3 start = path[i]; - Vector3 end = path[(i + 1) % path.Length]; - Gizmos.DrawLine(start, end); + if (contours[i].Count > 2) + { + // 杞崲鍧愭爣 + List worldPoints = ConvertToWorldCoordinates(contours[i], textureWidth, textureHeight); + + // 璁剧疆褰撳墠杞粨璺緞 + polygonCollider.SetPath(i, worldPoints); + + totalPoints += worldPoints.Count; + + Debug.Log($"杞粨 {i}: {worldPoints.Count} 涓偣"); + } + else + { + // 鐐瑰お灏戯紝璁剧疆绌鸿矾寰 + polygonCollider.SetPath(i, new Vector2[0]); + } } + + Debug.Log($"纰版挒浣撳垱寤烘垚鍔: {contours.Count} 涓疆寤擄紝鍏 {totalPoints} 涓《鐐"); + + // 鏄剧ず纰版挒浣撹竟鐣屼俊鎭 + Bounds bounds = polygonCollider.bounds; + Debug.Log($"纰版挒浣撹竟鐣: 涓績({bounds.center.x:F2}, {bounds.center.y:F2}), 澶у皬({bounds.size.x:F2}, {bounds.size.y:F2})"); + } + else + { + polygonCollider.pathCount = 0; + Debug.Log("娌℃湁鏈夋晥杞粨锛屾竻闄ょ鎾炰綋"); } } + List ImprovedContourConnection(List points) + { + if (points.Count < 3) + { + Debug.Log("鐐瑰お灏戯紝鏃犳硶褰㈡垚杞粨"); + return new List(); + } + + // 鏂规硶1锛氱洿鎺ヨ繑鍥炲師濮嬬偣锛堟寜缁嗚優椤哄簭锛 + Debug.Log($"鐩存帴杩斿洖 {points.Count} 涓偣锛堟湭鎺掑簭锛"); + return points; + + // 鎴栬呮柟娉2锛氱畝鍗曠殑鎸塝鐒跺悗X鎺掑簭 + // List sorted = points.OrderBy(p => p.y).ThenBy(p => p.x).ToList(); + // return sorted; + } + + List CollectAllEdgePoints(float[,] grid, float checkValue) + { + List allEdgePoints = new List(); + for (int y = 0; y < grid.GetLength(1) - 1; y++) + { + for (int x = 0; x < grid.GetLength(0) - 1; x++) + { + int cellstate = CalculateCellState(x, y, grid, checkValue); + if (cellstate != 0 && cellstate != 15) + { + List edgePoints = FindEdgePointsInCell(x, y, cellstate, grid, checkValue); + allEdgePoints.AddRange(edgePoints); + } + } + } + Debug.Log($"鏀堕泦鍒 {allEdgePoints.Count} 涓瓑鍊肩偣"); + + // 鏄剧ず鍓10涓偣浣滀负绀轰緥 + for (int i = 0; i < Mathf.Min(10, allEdgePoints.Count); i++) + { + Debug.Log($"鐐 {i}: ({allEdgePoints[i].x:F2}, {allEdgePoints[i].y:F2})"); + } + return allEdgePoints; + } + List FindEdgePointsInCell(int x, int y, int cellState, float[,] grid, float checkValue) + { + List edges = new List(); + bool p0 = (cellState & 1) != 0; + bool p1 = (cellState & 2) != 0; + bool p2 = (cellState & 4) != 0; + bool p3 = (cellState & 8) != 0; + if (p0 != p1) + { + Vector2 point = CalculateEdgePoint(x, y,CellEdge.Bottom, grid, checkValue); + edges.Add(point); + } + if (p1 != p2) + { + Vector2 point = CalculateEdgePoint(x, y, CellEdge.Right, grid, checkValue); + edges.Add(point); + } + if (p2 != p3) + { + Vector2 point = CalculateEdgePoint(x, y, CellEdge.Top, grid, checkValue); + edges.Add(point); + } + if (p3 != p0) + { + Vector2 point = CalculateEdgePoint(x, y, CellEdge.Left, grid, checkValue); + edges.Add(point); + } + return edges; + } + Vector2 CalculateEdgePoint(int x, int y, CellEdge cellEdge, float[,] grid, float checkValue) + { + Vector2 p1 = Vector2.zero, p2 = Vector2.zero; + float v1 = 0, v2 = 0; + switch (cellEdge) + { + case CellEdge.Bottom: + p1 = new Vector2(x, y); + p2 = new Vector2(x+1, y); + v1 = grid[x, y]; + v2 = grid[x+1, y]; + break; + case CellEdge.Right: + p1 = new Vector2(x+1, y); + p2 = new Vector2(x + 1, y+1); + v1 = grid[x + 1, y]; + v2 = grid[x + 1, y + 1]; + break; + case CellEdge.Top: + p1 = new Vector2(x + 1, y + 1); + p2 = new Vector2(x , y + 1); + v1 = grid[x + 1, y + 1]; + v2 = grid[x, y + 1]; + break; + case CellEdge.Left: + p1 = new Vector2(x, y + 1); + p2 = new Vector2(x , y); + v1 = grid[x, y + 1]; + v2 = grid[x , y]; + break; + default: + break; + } + float t = (checkValue-v1)/(v2 - v1); + return Vector2.Lerp(p1, p2, t); + } + int CalculateCellState(int x,int y, float[,] grid,float checkValue ) + { + int state = 0; + if (grid[x, y] <= checkValue) state |= 1; + if (grid[x+1, y] <= checkValue) state |= 2; + if (grid[x+1, y+1] <= checkValue) state |= 4; + if (grid[x, y + 1] <= checkValue) state |= 8; + return state; + } + /// + /// 姝g‘鐨凪arching Squares杞粨鐢熸垚锛堝甫鏂瑰悜璺熻釜锛 + /// + List> GenerateContours(float[,] grid, float isoLevel, int width, int height) + { + List> contours = new List>(); + bool[,] visited = new bool[width - 1, height - 1]; + + for (int y = 0; y < height - 1; y++) + { + for (int x = 0; x < width - 1; x++) + { + if (visited[x, y]) continue; + + int cellState = CalculateCellState(x, y, grid, isoLevel); + + // 鍙鐞嗘湁杈圭晫绌胯繃鐨勭粏鑳 + if (cellState > 0 && cellState < 15) + { + List contour = TraceContour(x, y, grid, isoLevel, width, height, visited); + if (contour != null && contour.Count > 2) + { + contours.Add(contour); + } + } + } + } + + return contours; + } + + /// + /// 璺熻釜涓涓疆寤擄紙鎸夎杩涙柟鍚戯級 + /// + List TraceContour(int startX, int startY, float[,] grid, float isoLevel, int width, int height, bool[,] visited) + { + List contour = new List(); + int x = startX; + int y = startY; + int entryEdge = 0; // 杩涘叆杈癸紝浠庝笅杈瑰紑濮 + + do + { + if (x < 0 || x >= width - 1 || y < 0 || y >= height - 1) break; + + visited[x, y] = true; + int cellState = CalculateCellState(x, y, grid, isoLevel); + + // 鏍规嵁缁嗚優鐘舵佸拰杩涘叆杈瑰喅瀹氬嚭鍙h竟 + int exitEdge = GetExitEdge(cellState, entryEdge); + + if (exitEdge == -1) break; + + // 璁$畻褰撳墠杈圭殑绛夊肩偣 + Vector2 point = CalculateEdgePoint(x, y, (CellEdge)exitEdge, grid, isoLevel); + contour.Add(point); + + // 绉诲姩鍒颁笅涓涓粏鑳 + switch (exitEdge) + { + case 0: // 浠庝笅杈瑰嚭锛屽悜涓嬬Щ鍔 + y--; + entryEdge = 2; // 杩涘叆涓婅竟 + break; + case 1: // 浠庡彸杈瑰嚭锛屽悜鍙崇Щ鍔 + x++; + entryEdge = 3; // 杩涘叆宸﹁竟 + break; + case 2: // 浠庝笂杈瑰嚭锛屽悜涓婄Щ鍔 + y++; + entryEdge = 0; // 杩涘叆涓嬭竟 + break; + case 3: // 浠庡乏杈瑰嚭锛屽悜宸︾Щ鍔 + x--; + entryEdge = 1; // 杩涘叆鍙宠竟 + break; + } + + } while (!(x == startX && y == startY) && contour.Count < 1000); + + return contour; + } + + /// + /// 鏍规嵁缁嗚優鐘舵佸拰杩涘叆杈硅幏鍙栧嚭鍙h竟 + /// + int GetExitEdge(int cellState, int entryEdge) + { + // 绠鍖栫殑鏌ユ壘琛 [缁嗚優鐘舵, 杩涘叆杈筣 -> 鍑哄彛杈 + // 杩欐槸涓涓畝鍖栫増鏈紝瀹為檯闇瑕佸畬鏁寸殑16x4鏌ユ壘琛 + switch (cellState) + { + case 1: // 0001 + case 14: // 1110 + return (entryEdge == 0) ? 3 : 0; + case 2: // 0010 + case 13: // 1101 + return (entryEdge == 1) ? 0 : 1; + case 4: // 0100 + case 11: // 1011 + return (entryEdge == 2) ? 1 : 2; + case 8: // 1000 + case 7: // 0111 + return (entryEdge == 3) ? 2 : 3; + case 3: // 0011 + case 12: // 1100 + return (entryEdge == 0) ? 1 : 0; + case 6: // 0110 + case 9: // 1001 + return (entryEdge == 1) ? 2 : 1; + default: + return -1; + } + } + // 鍦ㄧ被鏈熬娣诲姞Gizmos鏂规硶锛堟敮鎸佸涓疆寤擄級 + void OnDrawGizmosSelected() + { + PolygonCollider2D polygonCollider = GetComponent(); + if (polygonCollider != null && polygonCollider.pathCount > 0) + { + for (int pathIndex = 0; pathIndex < polygonCollider.pathCount; pathIndex++) + { + Vector2[] path = polygonCollider.GetPath(pathIndex); + + if (path.Length < 3) continue; + + // 姣忎釜杞粨鐢ㄤ笉鍚岄鑹 + Color[] colors = { Color.green, Color.blue, Color.yellow, Color.cyan, Color.magenta }; + Gizmos.color = colors[pathIndex % colors.Length]; + + // 缁樺埗杞粨绾 + for (int i = 0; i < path.Length; i++) + { + Vector3 start = transform.TransformPoint(path[i]); + Vector3 end = transform.TransformPoint(path[(i + 1) % path.Length]); + Gizmos.DrawLine(start, end); + } + + // 鏄剧ず椤剁偣 + Gizmos.color = Color.red; + foreach (Vector2 point in path) + { + Vector3 worldPoint = transform.TransformPoint(point); + Gizmos.DrawSphere(worldPoint, 0.005f); + } + } + + Debug.Log($"Gizmos鏄剧ず {polygonCollider.pathCount} 涓疆寤"); + } + } + enum CellEdge + { + Bottom = 0, + Right = 1, + Top = 2, + Left = 3 + } } \ No newline at end of file diff --git a/Assets/Scripts/Test/Light/Test.renderTexture b/Assets/Scripts/Test/Light/Test.renderTexture new file mode 100644 index 0000000..c271482 --- /dev/null +++ b/Assets/Scripts/Test/Light/Test.renderTexture @@ -0,0 +1,40 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!84 &8400000 +RenderTexture: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Test + m_ImageContentsHash: + serializedVersion: 2 + Hash: 00000000000000000000000000000000 + m_ForcedFallbackFormat: 4 + m_DownscaleFallback: 0 + m_IsAlphaChannelOptional: 0 + serializedVersion: 5 + m_Width: 256 + m_Height: 256 + m_AntiAliasing: 1 + m_MipCount: -1 + m_DepthStencilFormat: 94 + m_ColorFormat: 8 + m_MipMap: 0 + m_GenerateMips: 1 + m_SRGB: 0 + m_UseDynamicScale: 0 + m_BindMS: 0 + m_EnableCompatibleFormat: 1 + m_EnableRandomWrite: 0 + m_TextureSettings: + serializedVersion: 2 + m_FilterMode: 1 + m_Aniso: 1 + m_MipBias: 0 + m_WrapU: 1 + m_WrapV: 1 + m_WrapW: 1 + m_Dimension: 2 + m_VolumeDepth: 1 + m_ShadowSamplingMode: 2 diff --git a/Assets/Scripts/Test/Light/Test.renderTexture.meta b/Assets/Scripts/Test/Light/Test.renderTexture.meta new file mode 100644 index 0000000..e0cf472 --- /dev/null +++ b/Assets/Scripts/Test/Light/Test.renderTexture.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e448e9d777c74fd44b39265dbda970d0 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 8400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset index 7537566..660a76a 100644 --- a/UserSettings/EditorUserSettings.asset +++ b/UserSettings/EditorUserSettings.asset @@ -21,6 +21,9 @@ EditorUserSettings: value: 5104055750510d5a0b5f547712205d44124f1d727a7d70657d7b1f32b4b66639 flags: 0 RecentlyUsedSceneGuid-5: + value: 5b04565703015b0d5d5f5c7047270f4446161e7a7d2d22362b2a4d66b4e26c6e + flags: 0 + RecentlyUsedSceneGuid-6: value: 5602500350545e5a540a0f7740210744444f1b2c7f7c73362f2f4962e0b7316e flags: 0 vcSharedLogLevel: diff --git a/UserSettings/Layouts/default-2022.dwlt b/UserSettings/Layouts/default-2022.dwlt index 3922edd..9f96f16 100644 --- a/UserSettings/Layouts/default-2022.dwlt +++ b/UserSettings/Layouts/default-2022.dwlt @@ -15,11 +15,11 @@ MonoBehaviour: m_PixelRect: serializedVersion: 2 x: 0 - y: 43 - width: 2560 - height: 1349 + y: 43.2 + width: 2048 + height: 1188.8 m_ShowMode: 4 - m_Title: Inspector + m_Title: Hierarchy m_RootView: {fileID: 2} m_MinSize: {x: 875, y: 721} m_MaxSize: {x: 10000, y: 10000} @@ -44,8 +44,8 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 2560 - height: 1349 + width: 2048 + height: 1188.8 m_MinSize: {x: 875, y: 300} m_MaxSize: {x: 10000, y: 10000} m_UseTopView: 1 @@ -69,7 +69,7 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 2560 + width: 2048 height: 30 m_MinSize: {x: 0, y: 0} m_MaxSize: {x: 0, y: 0} @@ -90,8 +90,8 @@ MonoBehaviour: m_Position: serializedVersion: 2 x: 0 - y: 1329 - width: 2560 + y: 1168.8 + width: 2048 height: 20 m_MinSize: {x: 0, y: 0} m_MaxSize: {x: 0, y: 0} @@ -114,8 +114,8 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 30 - width: 2560 - height: 1299 + width: 2048 + height: 1138.8 m_MinSize: {x: 300, y: 100} m_MaxSize: {x: 24288, y: 16192} vertical: 0 @@ -140,8 +140,8 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 1877 - height: 1299 + width: 1501.6 + height: 1138.8 m_MinSize: {x: 200, y: 100} m_MaxSize: {x: 16192, y: 16192} vertical: 1 @@ -166,8 +166,8 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 1877 - height: 865 + width: 1501.6 + height: 758.4 m_MinSize: {x: 200, y: 50} m_MaxSize: {x: 16192, y: 8096} vertical: 0 @@ -190,8 +190,8 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 407 - height: 865 + width: 325.6 + height: 758.4 m_MinSize: {x: 201, y: 221} m_MaxSize: {x: 4001, y: 4021} m_ActualView: {fileID: 13} @@ -214,10 +214,10 @@ MonoBehaviour: m_Children: [] m_Position: serializedVersion: 2 - x: 407 + x: 325.6 y: 0 - width: 1470 - height: 865 + width: 1176 + height: 758.4 m_MinSize: {x: 202, y: 221} m_MaxSize: {x: 4002, y: 4021} m_ActualView: {fileID: 14} @@ -241,26 +241,26 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 1 m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0} - m_Name: ConsoleWindow + m_Name: ProjectBrowser m_EditorClassIdentifier: m_Children: [] m_Position: serializedVersion: 2 x: 0 - y: 865 - width: 1877 - height: 434 - m_MinSize: {x: 101, y: 121} - m_MaxSize: {x: 4001, y: 4021} - m_ActualView: {fileID: 12} + y: 758.4 + width: 1501.6 + height: 380.40002 + m_MinSize: {x: 231, y: 271} + m_MaxSize: {x: 10001, y: 10021} + m_ActualView: {fileID: 21} m_Panes: - {fileID: 21} - {fileID: 22} - {fileID: 23} - {fileID: 12} - {fileID: 24} - m_Selected: 3 - m_LastSelected: 0 + m_Selected: 0 + m_LastSelected: 3 --- !u!114 &11 MonoBehaviour: m_ObjectHideFlags: 52 @@ -276,12 +276,12 @@ MonoBehaviour: m_Children: [] m_Position: serializedVersion: 2 - x: 1877 + x: 1501.6 y: 0 - width: 683 - height: 1299 - m_MinSize: {x: 276, y: 121} - m_MaxSize: {x: 4001, y: 4021} + width: 546.4 + height: 1138.8 + m_MinSize: {x: 275, y: 100} + m_MaxSize: {x: 4000, y: 4000} m_ActualView: {fileID: 25} m_Panes: - {fileID: 25} @@ -304,15 +304,15 @@ MonoBehaviour: m_MaxSize: {x: 4000, y: 4000} m_TitleContent: m_Text: Console - m_Image: {fileID: -4327648978806127646, guid: 0000000000000000d000000000000000, + m_Image: {fileID: -4950941429401207979, guid: 0000000000000000d000000000000000, type: 0} m_Tooltip: m_Pos: serializedVersion: 2 x: 0 - y: 938 - width: 1876 - height: 413 + y: 832 + width: 1500.6 + height: 359.40002 m_SerializedDataModeController: m_DataMode: 0 m_PreferredDataMode: 0 @@ -339,15 +339,15 @@ MonoBehaviour: m_MaxSize: {x: 4000, y: 4000} m_TitleContent: m_Text: Hierarchy - m_Image: {fileID: 7966133145522015247, guid: 0000000000000000d000000000000000, + m_Image: {fileID: -3734745235275155857, guid: 0000000000000000d000000000000000, type: 0} m_Tooltip: m_Pos: serializedVersion: 2 x: 0 - y: 73 - width: 406 - height: 844 + y: 73.6 + width: 324.6 + height: 737.4 m_SerializedDataModeController: m_DataMode: 0 m_PreferredDataMode: 0 @@ -363,7 +363,7 @@ MonoBehaviour: scrollPos: {x: 0, y: 0} m_SelectedIDs: m_LastClickedID: 0 - m_ExpandedIDs: 08fbffffe27c0000 + m_ExpandedIDs: fcfaffff m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -403,15 +403,15 @@ MonoBehaviour: m_MaxSize: {x: 4000, y: 4000} m_TitleContent: m_Text: Scene - m_Image: {fileID: 2593428753322112591, guid: 0000000000000000d000000000000000, + m_Image: {fileID: 8634526014445323508, guid: 0000000000000000d000000000000000, type: 0} m_Tooltip: m_Pos: serializedVersion: 2 - x: 407 - y: 73 - width: 1468 - height: 844 + x: 325.6 + y: 73.6 + width: 1174 + height: 737.4 m_SerializedDataModeController: m_DataMode: 0 m_PreferredDataMode: 0 @@ -783,9 +783,9 @@ MonoBehaviour: m_PlayAudio: 0 m_AudioPlay: 0 m_Position: - m_Target: {x: -0.6338736, y: 2.8792658, z: 9.9932} + m_Target: {x: 0.57438695, y: 0.61978495, z: 0.0037172732} speed: 2 - m_Value: {x: -0.6338736, y: 2.8792658, z: 9.9932} + m_Value: {x: 0.57438695, y: 0.61978495, z: 0.0037172732} m_RenderMode: 0 m_CameraMode: drawMode: 0 @@ -831,13 +831,13 @@ MonoBehaviour: m_GridAxis: 1 m_gridOpacity: 0.5 m_Rotation: - m_Target: {x: 0.1730932, y: 0.018612249, z: -0.0032754778, w: 0.98472977} + m_Target: {x: 0.10836062, y: 0.025340052, z: -0.002800803, w: 0.99380815} speed: 2 - m_Value: {x: 0.17309225, y: 0.018612146, z: -0.0032754599, w: 0.98472434} + m_Value: {x: 0.1083581, y: 0.025339464, z: -0.0028007377, w: 0.993785} m_Size: - m_Target: 8.308297 + m_Target: 0.6089797 speed: 2 - m_Value: 8.308297 + m_Value: 0.5827557 m_Ortho: m_Target: 0 speed: 2 @@ -878,15 +878,15 @@ MonoBehaviour: m_MaxSize: {x: 4000, y: 4000} m_TitleContent: m_Text: Game - m_Image: {fileID: -6423792434712278376, guid: 0000000000000000d000000000000000, + m_Image: {fileID: 4621777727084837110, guid: 0000000000000000d000000000000000, type: 0} m_Tooltip: m_Pos: serializedVersion: 2 - x: 407 - y: 73 - width: 1468 - height: 844 + x: 325.6 + y: 73.6 + width: 1174 + height: 737.4 m_SerializedDataModeController: m_DataMode: 0 m_PreferredDataMode: 0 @@ -918,10 +918,10 @@ MonoBehaviour: m_VRangeLocked: 0 hZoomLockedByDefault: 0 vZoomLockedByDefault: 0 - m_HBaseRangeMin: -1280 - m_HBaseRangeMax: 1280 - m_VBaseRangeMin: -720 - m_VBaseRangeMax: 720 + m_HBaseRangeMin: -1024 + m_HBaseRangeMax: 1024 + m_VBaseRangeMin: -576 + m_VBaseRangeMax: 576 m_HAllowExceedBaseRangeMin: 1 m_HAllowExceedBaseRangeMax: 1 m_VAllowExceedBaseRangeMin: 1 @@ -939,23 +939,23 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 21 - width: 1468 - height: 823 - m_Scale: {x: 0.5715278, y: 0.5715278} - m_Translation: {x: 733.99994, y: 411.5} + width: 1174 + height: 716.4 + m_Scale: {x: 0.5732422, y: 0.5732422} + m_Translation: {x: 587, y: 358.2} m_MarginLeft: 0 m_MarginRight: 0 m_MarginTop: 0 m_MarginBottom: 0 m_LastShownAreaInsideMargins: serializedVersion: 2 - x: -1284.277 - y: -720 - width: 2568.554 - height: 1440 + x: -1024 + y: -624.8668 + width: 2048 + height: 1249.7336 m_MinimalGUI: 1 - m_defaultScale: 0.5715278 - m_LastWindowPixelSize: {x: 1468, y: 844} + m_defaultScale: 0.5732422 + m_LastWindowPixelSize: {x: 1467.5, y: 921.75} m_ClearInEditMode: 1 m_NoCameraWarning: 1 m_LowResolutionForAspectRatios: 01000001000000000000 @@ -978,7 +978,7 @@ MonoBehaviour: m_MaxSize: {x: 4000, y: 4000} m_TitleContent: m_Text: Package Manager - m_Image: {fileID: -2824328813065806953, guid: 0000000000000000d000000000000000, + m_Image: {fileID: 5076950121296946556, guid: 0000000000000000d000000000000000, type: 0} m_Tooltip: m_Pos: @@ -1117,7 +1117,7 @@ MonoBehaviour: m_MaxSize: {x: 4000, y: 4000} m_TitleContent: m_Text: Asset Store - m_Image: {fileID: -8693916549880196297, guid: 0000000000000000d000000000000000, + m_Image: {fileID: -7444545952099596278, guid: 0000000000000000d000000000000000, type: 0} m_Tooltip: m_Pos: @@ -1152,15 +1152,15 @@ MonoBehaviour: m_MaxSize: {x: 10000, y: 10000} m_TitleContent: m_Text: Project - m_Image: {fileID: -5467254957812901981, guid: 0000000000000000d000000000000000, + m_Image: {fileID: -5179483145760003458, guid: 0000000000000000d000000000000000, type: 0} m_Tooltip: m_Pos: serializedVersion: 2 x: 0 - y: 938 - width: 1876 - height: 413 + y: 832 + width: 1500.6 + height: 359.40002 m_SerializedDataModeController: m_DataMode: 0 m_PreferredDataMode: 0 @@ -1182,7 +1182,7 @@ MonoBehaviour: m_SkipHidden: 0 m_SearchArea: 1 m_Folders: - - Assets/Scripts/Test/Light + - Assets m_Globs: [] m_OriginalText: m_ImportLogFlags: 0 @@ -1190,16 +1190,16 @@ MonoBehaviour: m_ViewMode: 1 m_StartGridSize: 16 m_LastFolders: - - Assets/Scripts/Test/Light + - Assets m_LastFoldersGridSize: 16 - m_LastProjectPath: C:\UnityProject\BlueArchiveMiniGame + m_LastProjectPath: D:\UnityProject\BlueArchiveMiniGame m_LockTracker: m_IsLocked: 0 m_FolderTreeState: scrollPos: {x: 0, y: 27} - m_SelectedIDs: ce7f0000 - m_LastClickedID: 32718 - m_ExpandedIDs: 00000000c47d0000c67d0000c87d0000ca7d0000cc7d0000ce7d0000d07d0000c47f0000ce7f000000ca9a3b + m_SelectedIDs: ba7d0000 + m_LastClickedID: 32186 + m_ExpandedIDs: 00000000ba7d000000ca9a3bffffff7f m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -1227,7 +1227,7 @@ MonoBehaviour: scrollPos: {x: 0, y: 0} m_SelectedIDs: m_LastClickedID: 0 - m_ExpandedIDs: 00000000c47d0000c67d0000c87d0000ca7d0000cc7d0000ce7d0000d07d0000 + m_ExpandedIDs: 00000000ba7d0000 m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -1299,7 +1299,7 @@ MonoBehaviour: m_MaxSize: {x: 4000, y: 4000} m_TitleContent: m_Text: Animator - m_Image: {fileID: -1673928668082335149, guid: 0000000000000000d000000000000000, + m_Image: {fileID: 1711060831702674872, guid: 0000000000000000d000000000000000, type: 0} m_Tooltip: m_Pos: @@ -1423,7 +1423,7 @@ MonoBehaviour: m_MaxSize: {x: 4000, y: 4000} m_TitleContent: m_Text: Animation - m_Image: {fileID: -8166618308981325432, guid: 0000000000000000d000000000000000, + m_Image: {fileID: -3237396543322336831, guid: 0000000000000000d000000000000000, type: 0} m_Tooltip: m_Pos: @@ -1444,7 +1444,7 @@ MonoBehaviour: m_OverlaysVisible: 1 m_LockTracker: m_IsLocked: 0 - m_LastSelectedObjectID: -21542028 + m_LastSelectedObjectID: 32004 --- !u!114 &24 MonoBehaviour: m_ObjectHideFlags: 52 @@ -1461,7 +1461,7 @@ MonoBehaviour: m_MaxSize: {x: 4000, y: 4000} m_TitleContent: m_Text: Audio Mixer - m_Image: {fileID: 2344599766593239149, guid: 0000000000000000d000000000000000, + m_Image: {fileID: -3283902137440876849, guid: 0000000000000000d000000000000000, type: 0} m_Tooltip: m_Pos: @@ -1644,15 +1644,15 @@ MonoBehaviour: m_MaxSize: {x: 4000, y: 4000} m_TitleContent: m_Text: Inspector - m_Image: {fileID: -2667387946076563598, guid: 0000000000000000d000000000000000, + m_Image: {fileID: -440750813802333266, guid: 0000000000000000d000000000000000, type: 0} m_Tooltip: m_Pos: serializedVersion: 2 - x: 1877 - y: 73 - width: 682 - height: 1278 + x: 1501.6 + y: 73.6 + width: 545.4 + height: 1117.8 m_SerializedDataModeController: m_DataMode: 0 m_PreferredDataMode: 0 @@ -1692,7 +1692,7 @@ MonoBehaviour: m_MaxSize: {x: 4000, y: 4000} m_TitleContent: m_Text: Lighting - m_Image: {fileID: -1347227620855488341, guid: 0000000000000000d000000000000000, + m_Image: {fileID: -1477008817101679558, guid: 0000000000000000d000000000000000, type: 0} m_Tooltip: m_Pos: