Shader to eliminate overlap of semi-transparent objects

I’ve been working with ghost figures using semi-transparent shaders I wrote which display the figure faded out to varying degrees (and sometimes with a slight refraction effect). This only works if the figure is a single mesh, otherwise multiple meshes sometimes overlap and create areas that are tinted more than the rest, which looks bad. Is there any way I can prevent this ?

Make a shader with 2 subshaders. One only writes to depth, not color. It will need to use Tags { “Queue” = “Transparent-1” } to time it to be right before transparent things get rendered.

The second subshader can be the regular, transparent shader you are already using. But, with ZTest set to Equal.

The first pass lays down the z-values for all of the transparent objects. The second pass goes back over the transparent objects and draws only their pixels that are most in front.

1 Like

Thank you. I’ll have to try that.

Hi, Did you find the solution?