eduilnero

Hi there!

I am having some issues with URP water shaders and Spine's Skeleton Lit (URP). First, I need Spine's to write Z buffer so I modified the one in the URP package to do it, otherwise I only render on top of the water or below in order and I cannot get the character rendering with part of the body underwater for example. But when I fix this I get some artifacts like the ones in the picture. The alpha space between the outline of the character and the end of the mesh seems to get the color of the terrain (it ignores water) so it is not painting properly. Do you have any ideas?
Nemaš dopuštenje za pregledavanje privit(a)ka dodan(og)ih postu.
eduilnero
  • Postovi: 2

Harald

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.
Avatar
Harald

Harri
  • Postovi: 3589

eduilnero

Oh man, this was exactly the issue. I am not an expert in shaders and was running out of ideas.
Your solution works perfect. Thank you very much!
eduilnero
  • Postovi: 2

Harald

Glad to hear, thanks for getting back to us! :)
Avatar
Harald

Harri
  • Postovi: 3589


Natrag na Unity