In Unity URP, AlphaTest Shader's shadows are displayed the same

I am a developer who has just started programming shaders.

I’m making a shader that renders shadows while using alphatest in a Unity URP environment.

However, as shown in the following figure, there is a problem that the shadows are rendered the same even though they are different objects.

I checked in the Frame Debugger that the texture doesn’t change when creating the Shadowmap.

The project environment is as follows:
Unity version: 2019.4.21
URP version: 7.5.3
Project repository: GitHub - lklab/UnityURPAlphaTestShadow
My shader code: UnityURPAlphaTestShadow/Assets/Shaders/URPAlphaTestUnlitShadow.shader at master · lklab/UnityURPAlphaTestShadow · GitHub

I would be very grateful if you could help.

※ I’m already using Opaque and AlphaTest (AlphaClip).

I solved it.
The problem was due to the SRP batcher.
I solved it by writing the same CBUFFER for all passes in the shader like this:

TEXTURE2D(_MainTex);
TEXTURE2D(_LightTex);
SAMPLER(sampler_MainTex);
SAMPLER(sampler_LightTex);

CBUFFER_START(UnityPerMaterial)
half4 _MainTex_ST;
half4 _LightTex_ST;
CBUFFER_END

I have also updated the Project repository.

1 Like