Custom shadow caster bug

Hey

So I want to create my own shadow caster pass, I’m using the code from unity’s documentation,
but the result is not good. I get this thin shadow line affected by the Normal Bias on the light.

The code is the same as Legacy Shaders/VertexLit/SHADOWCASTER pass.

if I use UsePass “Legacy Shaders/VertexLit/SHADOWCASTER” instead of my custom pass it’s working…

What am I missing?

    Properties
    {
        _MainTex ("Texture", 2D) = "grey" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" "LightMode" = "ForwardBase"}

        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma multi_compile_fwdbase
         
            #include "UnityCG.cginc"
            #include "AutoLight.cginc"
         
            struct appdata
            {
                float4 vertex     : POSITION;
                float2 uv         : TEXCOORD0;
            };

            struct v2f
            {
                float4 pos         : SV_POSITION;
                float2 uv         : TEXCOORD0;
                float3 worldPos : TEXCOORD1;
             
                SHADOW_COORDS(2)
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;
         
            v2f vert (appdata v)
            {
                v2f o;
                o.pos                 = mul(UNITY_MATRIX_MVP, v.vertex);
                o.uv                 = TRANSFORM_TEX(v.uv, _MainTex);
                o.worldPos             = mul(_Object2World, v.vertex);
                TRANSFER_SHADOW(o)
             
                return o;
            }
         
            fixed4 frag (v2f i) : SV_Target
            {
         
                // Atten
                UNITY_LIGHT_ATTENUATION(atten, i, i.worldPos)
                // sample the texture
                fixed4 col = tex2D(_MainTex, i.uv);
         
                return col * atten;
            }
            ENDCG
        }
     
        // shadow caster rendering pass
        Pass {
            Name "ShadowCaster"
            Tags { "LightMode" = "ShadowCaster" }
         
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma multi_compile_shadowcaster
            #include "UnityCG.cginc"

            struct v2f {
                V2F_SHADOW_CASTER;
            };

            v2f vert( appdata_base v )
            {
                v2f o;
                TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
                return o;
            }

            float4 frag( v2f i ) : SV_Target
            {
                SHADOW_CASTER_FRAGMENT(i)
            }
            ENDCG
        }
// Works with this line
    //UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
    }
// Works with this line
        //Fallback "Diffuse"
}

If I use the code straight from unity’s doc

Shader “Lit/Shadow Casting”

I get the same problem.

Turns out that if I set my Tags outside the first Pass{} (ForwardBase) it doesn’t work, but when I set it inside Pass{} it works.