Skip to content

Commit 891034b

Browse files
committed
解决深度偏移边缘光DepthOnly SRP Batcher不兼容的问题
1 parent 1e2a3ea commit 891034b

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

Assets/Shaders/NPR/Cartoon/Rimlight (Depth Offset).shader

+31-6
Original file line numberDiff line numberDiff line change
@@ -166,24 +166,49 @@ Shader "Lakehani/URP/NPR/Cartoon/Rimlight Depth Offset"
166166

167167
Pass
168168
{
169+
//参考
170+
//Packages/com.unity.render-pipelines.universal/Shaders/UnlitInput.hlsl
171+
//Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl
169172
//写入深度图
170173
Name "DepthOnly"
171174
Tags{"LightMode" = "DepthOnly"}
172175

173-
Cull Back
174-
Blend One Zero
175-
ZTest LEqual
176+
Name "DepthOnly"
177+
Tags{"LightMode" = "DepthOnly"}
178+
176179
ZWrite On
177180
ColorMask 0
178181

179182
HLSLPROGRAM
180-
// Required to compile gles 2.0 with standard srp library
181183

182184
#pragma vertex DepthOnlyVertex
183185
#pragma fragment DepthOnlyFragment
184186

185-
#include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitInput.hlsl"
186-
#include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
187+
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
188+
189+
struct Attributes
190+
{
191+
float4 position : POSITION;
192+
};
193+
194+
struct Varyings
195+
{
196+
float4 positionCS : SV_POSITION;
197+
};
198+
199+
Varyings DepthOnlyVertex(Attributes input)
200+
{
201+
Varyings output;
202+
output.positionCS = TransformObjectToHClip(input.position.xyz);
203+
return output;
204+
}
205+
206+
half4 DepthOnlyFragment(Varyings input) : SV_TARGET
207+
{
208+
209+
return 0;
210+
}
211+
187212
ENDHLSL
188213
}
189214
}

0 commit comments

Comments
 (0)