Hi, I wrote a basic shader and added a shadow caster pass, but it is not showing up on the depth texture. Objects in the scene with default URP shaders do properly show depth, so I think my project settings are ok and the issue is with my code. Is there something wrong with my shadow caster pass?
Shader "Custom/Land"
{
Properties
{
_BaseMap ("Base Texture", 2D) = "white" {}
_LightDir ("Light Direction", Vector) = (-1, 1 ,-1, 0)
_AmbientLight ("Ambient Light", Vector) = (0.1, 0.1, 0.1, 0.1)
}
SubShader
{
Tags {
"RenderPipeline"="UniversalPipeline"
"Queue"="Geometry"
}
HLSLINCLUDE
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
CBUFFER_START(UnityPerMaterial)
float4 _BaseMap_ST;
float4 _LightDir;
float4 _AmbientLight;
CBUFFER_END
ENDHLSL
Pass
{
Name "ForwardPsuedoLit"
Tags { "LightMode"="UniversalForward" }
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
TEXTURE2D(_BaseMap);
SAMPLER(sampler_BaseMap);
struct MeshData
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
float2 uv : TEXCOORD0;
float4 color: COLOR;
};
struct v2f
{
float4 positionCS : SV_POSITION;
float3 normalWS : NORMAL;
float2 uv : TEXCOORD0;
float4 color : COLOR;
};
v2f vert (MeshData i)
{
v2f o;
VertexPositionInputs positionInputs = GetVertexPositionInputs(i.positionOS.xyz);
VertexNormalInputs normalInputs = GetVertexNormalInputs(i.normalOS);
o.positionCS = positionInputs.positionCS;
o.normalWS = normalInputs.normalWS;
o.uv = TRANSFORM_TEX(i.uv, _BaseMap);
o.color = i.color;
return o;
}
float4 frag (v2f i) : SV_Target
{
float NdotL = dot(_LightDir, i.normalWS);
if (NdotL < 0) { NdotL = 0; }
return i.color * NdotL + _AmbientLight;
}
ENDHLSL
}
Pass {
Name "ShadowCaster"
Tags { "LightMode"="ShadowCaster" }
ZWrite On
ZTest LEqual
ColorMask 0
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
struct MeshData {
float4 positionOS : POSITION;
};
struct v2f {
float4 positionCS : SV_POSITION;
};
v2f vert(MeshData i) {
v2f o;
VertexPositionInputs positionInputs = GetVertexPositionInputs(i.positionOS.xyz);
o.positionCS = positionInputs.positionCS;
return o;
}
float4 frag(v2f i) : SV_TARGET {
return 0;
}
ENDHLSL
}
}
}