Hi and welcome to the forum! 🙂
This most likely is due to the shader writing to the ZBuffer all the time, even when the pixel is 100% transparent (in other words pixel.alpha == 0
). What you need is to discard pixels that are below an alpha threshold value, in shader code that would be clip((pixel.a * color.a) - _Cutoff);
. This is equivalent to if (pixel.a * color.a < _Cutoff) discard;
.
You could have a look at how the Spine-Skeleton-Lit-ZWrite.shader
(the non-URP shader) performs the alpha-based clipping. The shader calls ALPHA_CLIP(tex, i.color);
which is defined as clip((pixel.a * color.a) - _Cutoff);
above.
You just need to be sure to introduce a _Cutoff
parameter as can be seen here.
And when using the ALPHA_CLIP
macro instead of clip(..)
you also need to #define _ALPHA_CLIP
as shown here.