Heya yall, I’m trying to make a shadow caster that obeys the alpha clipping on the color pass of my shader. I know there’s something off with my code and I was wondering what to do with it to fix it.
Pass //Shadow Pass
{
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
ZWrite On
ColorMask 0
Cull Back
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_instancing
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
TEXTURE2D(_MainTex);
SAMPLER(sampler_MainTex);
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
float2 uv : TEXCOORD2;
};
struct Varyings
{
float4 positionHCS : SV_POSITION;
float2 uv : TEXCOORD2;
};
//Cbuffer Declaration
CBUFFER_START(UnityPerMaterial)
float4 _MainTex_ST;
CBUFFER_END
//Declaring Properties
float4 _Color;
Varyings vert (Attributes IN)
{
Varyings OUT;
float3 positionWS = TransformObjectToWorld(IN.positionOS.xyz);
//OUT.positionHCS = TransformWorldToHClip(ApplyShadowBias(positionWS, TransformObjectToWorldNormal(IN.normalOS)));
OUT.uv = TRANSFORM_TEX(IN.uv, _MainTex); // Transform UVs
return OUT;
}
half4 frag (Varyings IN) : SV_Target
{
float culling = step(0.5, 1 - SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv)); //Create Culling Gradient
clip(culling);
return 0;
}
ENDHLSL
}