I have a custom shader that I want to only cast shadows. I got it to cast shadows, but now the mesh isn’t rendering. I’m a beginner at shader scripting and would appreciate any help.
What it looks like:

Shader Script:
Shader "Custom/WitnessFoliage" {
Properties {
_EdgeTransparency ("Edge Transparency", Range (0, 1)) = 0.3 // Control edge transparency
_Cutoff ("Alpha Cutoff", Range (0, 1)) = 0.5 // Adjust this threshold for leaf transparency
_Color ("Tint", Color) = (1, 1, 1, 1) // Leaf color
_MainTex ("Leaf Texture", 2D) = "white" // Texture for the leaves
}
SubShader {
Tags {
"Queue"="AlphaTest"
"RenderType"="TransparentCutout"
}
Pass {
Name "ShadowCaster"
Tags { "LightMode"="ShadowCaster" }
ZWrite On
ZTest LEqual
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f {
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _Color;
float _Cutoff;
float _EdgeTransparency;
v2f vert (appdata_t v) {
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
half4 frag (v2f i) : SV_Target {
half4 texColor = tex2D(_MainTex, i.uv);
half alpha = texColor.a * _EdgeTransparency;
clip(alpha - _Cutoff);
half4 finalColor = _Color * texColor;
finalColor.a = step(_Cutoff, alpha);
return finalColor;
}
ENDCG
HLSLPROGRAM
#pragma vertex ShadowPassVertex
#pragma fragment ShadowPassFragment
// Material Keywords
#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
// GPU Instancing
#pragma multi_compile_instancing
// (Note, this doesn't support instancing for properties though. Same as URP/Lit)
// #pragma multi_compile _ DOTS_INSTANCING_ON
// (This was handled by LitInput.hlsl. I don't use DOTS so haven't bothered to support it)
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
ENDHLSL
}
}
}
Thank you again!
– Hero_Holmes360