[LWRP/URP] Depth pre-pass for depth testing

Hi,

I am running in a bit of a problem rendering vegetation on screen. Its not even covering a lot of the screen, but the performance impact is quite high. The vegetation is rendered using alpha-testing, which causes a lot of overdraw. Other engines seem to take advantage of the depth pre-pass to depth-reject occluded pixels in the lit-shader passes, making it much more affordable.

From my tests and some vague posts I found about the topic, it seems that LWRP/URP doesn’t use the depth pre-pass for depth-testing, but only for shadows and post-processing.

Is there any way to get this to work? Without it, rendering lots of vegetation seems like a rather impossible task in Unity.

Thanks for any hints and tips :slight_smile:

2 Likes

We have plan to support this as an option in the renderer, however it’s not done yet. Only way to do it atm is to change URP source.

2 Likes

any news about it?

Still being worked on as it requires several steps on our part.
phil_lira and me are actively working on those. Can’t promise a release date but hopefully very soon.

2 Likes

thks for answer.
may we will get manual passes in shader graph or standard base shader code like we have in standard rp?

I believe depth prepass is not a good deal ,but I would like to test it anyway to see if improves the fill rate (I doubt so). Is the feature now available?

Hi both, is there any update on this? Ran into this issue on Oculus Quest with a water shader using Scene Depth node for an edge-foam effect, anything rendering in front of the water has aliased shimmering white around it where the non-MSAA depth pass is added on top (I assume).

6076080--659031--msaadepth.PNG

If you’re rendering a depth or depth/normals pass anyway (for postprocessing, particularly SSAO now that the URP supports it), that should be able to serve as a free prepass

But as far as I could see (only tested in the editor), the depth buffer is not preserved between the depth-normals pass and the main render pass.

Not sure if it’s possible to change this by hacking at the URP code - as it would involve dealing with color and depth buffers as separate objects (rather than a RenderTexture which contains both)

1 Like