Hello,
I am trying to come up with a solution for my simple water voxel simulation in URP project. I need a transparent material that renders only front faces with ZTest on. The material would not blend other transparent faces behind it. To make things even more complicated, it should work on multiple objects.
This topic was discussed years ago here: https://discussions.unity.com/t/transparent-solid-color-shader/47539
But none of the solution work with current version of Unity.
Here is an example image. I want to achieve the effect on the lower image.
Thanks, Jan
Render the transparent objects with depth-only pass, omitting any color writes. Then render transparent materials with depth test on and depth write off.
The problem is that Unity (at least the built-in renderer) will always render additional material passes together, so, in order to blend multiple objects correctly, you need to split the whole thing into two materials (first material with depth only pass, second material with visible transparent shader) and set them apart in render queue. Then give each renderer both materials.
I had partial success with RenderToTexture in separate render layer. But the separate layer shows through other geometry. Zdepth problem again.
Here is a image what it looks like
and another one, what it should look like
For anyone interested. ShaderGraph setup for both materials. First one on the left, second one on the right.