Shadows not working properly on geometry shader

Hey, so I’m kind of new to geometry shaders. I’ve been experimenting with this grass shader, and I’ve gotten shadows to work, sort of.
6783449--785375--upload_2021-1-30_20-51-27.png
As you can see, shadows go “through” the geometry.
6783449--785378--upload_2021-1-30_20-52-32.png

In my geometry shader I do this.

TRANSFER_SHADOW(o);

Where o is a custom struct geometryOutput

        struct geometryOutput {
            float4 pos : SV_POSITION;
            float3 uv : TEXCOORD0;
            float3 pos_ws : TEXCOORD1;
            unityShadowCoord4 _ShadowCoord : TEXCOORD2;
        };

And then in my fragment shader I sample it like so

            float atten = SHADOW_ATTENUATION(i) + 1;
            atten /= 2;

I have run into this issue before when working with unlit shaders, but that was solved by using a fallback to vertexLit (So I’m assuming something is missing here that “writes” to the shadows, so to speak)

I have tried implementing a ShadowCollector pass, but that hasn’t given any effect. Altough that might be because I don’t really understand ShadowCollector passes and haven’t found any resources regarding them.

So… is the ShadowCollector pass what’s needed here, or is there something else?

One thing to add. I did sort of solve this issue with another geometry shader I was working on, by calculating the shadow position with the world space position of the base vertex instead of the object space, altough it was an imperfect soloution, as the shading was then done per vertex with leads to some artifacting if you have large triangles.
So maybe there’s something about unity “compressing” object space positions. I honestly have no clue.

The explicit “shadow collector” pass got phased out of Unity with Unity 5.0, some 6 years ago. However that’s because the shadow caster pass pulls double duty now as both the shadow caster and effectively the shadow collector pass by way of being used to render the camera depth texture.