This repository was archived by the owner on Jun 17, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change 9595 Name "ShadowCaster"
9696 Tags { "LightMode" = "ShadowCaster" }
9797
98+ Cull Back
99+ ZWrite On
100+ ZTest LEqual
101+
98102 HLSLPROGRAM
99103 #pragma vertex vert
100104 #pragma fragment frag
101-
102105 #pragma multi_compile_instancing
103106
104107 #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
105- #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShadowCasterPass.hlsl"
106108
107109 struct Attributes
108110 {
109111 float4 vertex : POSITION ;
110112 float3 normal : NORMAL ;
113+ UNITY_VERTEX_INPUT_INSTANCE_ID
111114 };
112115
113116 struct Varyings
114117 {
115118 float4 positionCS : SV_POSITION ;
119+ UNITY_VERTEX_OUTPUT_STEREO
116120 };
117121
118122 Varyings vert (Attributes input)
119123 {
120124 Varyings output;
121- float3 positionWS = TransformObjectToWorld (input.vertex.xyz);
122- float3 normalWS = TransformObjectToWorldNormal (input.normal);
123- output.positionCS = GetShadowCasterPositionCS (input.vertex, normalWS);
125+ UNITY_SETUP_INSTANCE_ID (input);
126+ UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO (output);
127+
128+ float3 worldPos = TransformObjectToWorld (input.vertex.xyz);
129+ float3 worldNormal = TransformObjectToWorldNormal (input.normal);
130+
131+ worldPos += worldNormal * 0.001 ; //prevent zfighting spots
132+
133+ output.positionCS = TransformWorldToHClip (worldPos);
124134 return output;
125135 }
126136
127137 float4 frag (Varyings input) : SV_Target
128138 {
129- return 0 ;
139+ return 0.0 ;
130140 }
131141 ENDHLSL
132142 }
You can’t perform that action at this time.
0 commit comments