Fade object with Renderer feature render objects depth writing

Hello, I’m doing a fading shader like the one in unity documentation (Transparent shader with depth writes)
The principle is quite simple I made a shader that writes depth like this :

        Pass
        {
            ZWrite On
            ZTest LEqual
            ColorMask 0 // remove the white color
        }

In urp we cannot have multipass shader graph so I use two materials on the same mesh renderer to make it work. The first material is the depth write shader and the second is a urp lit transparent material.
I get the desired result :


It works great !
But I actually need to make the same effect with renderer features because I do not have control over every mesh renderers and some of them have multiple materials (one for each submeshes).
So I thought it should be quite simple, that is exactly what render objects in the renderer features is made for !

yet it does not work correctly, we can slightly see the door inside the mesh.
I tried to set different events for the render objects but I cannot get it to work.

Hello it’s been two months and I still need this, is there anyone who can help ?

Hi, I might be able to help with a C# script I’m working on for myself, I’ll try and get back to you soon.

Hi, that’s an interesting effect! Did you happen to figure out the solution?

No sorry I haven’t found a solution yet !

1 Like

You can achieve an additional pass in your shader by giving it a different LightMode tag, eg ‘FadeDepth’. Then use the LightMode setting from your renderfeatures to draw this pass. You might need two RenderFeatures, one to do the depth and the other to draw using the standard pass.