Why does clear depth kill the depth for the overlay camera?

in order for an overlay camera to do what its only purpose is (overlay)… you must check the clear depth checkbox. This immediately breaks the depth for the overlay layer… All the post that uses that depth info is broken and transparents are broken. if this is how it’s supposed to work then how is camera stacking not a broken feature marked as preview feature? I’ve seen many threads on this issue going back a couple years. forgive my frustration but my months of development have come to a halt because of this and wish someone would have told me not to use URP and spend hundreds of dollars and URP assets that don’t work with camera stacking.

1 Like

Copy depth buffer from the original camera and manually insert it before post process stage on overlay. Its a workaround, not perfect, but will get the job done.
Our game uses depth of field on base camera as render feature and on its final pass, we manually push depth data into the buffer so that overlay camera can render particles and other stuff that we don’t want to be blurred (mostly transparent objects that doesn’t do depth writes but uses depth testing).

I’m uncertain whether my case will help but I hope it helps.

Thanks for the reply. I want to try that but don’t know how. I assume the depth buffer can be copied in a custom render feature? is there an example render feature that i can find somewhere? Thanks…

Also, does clearing the depth buffer stop transparents from working on the overlay camera? im still confused as to why that is happening.

plus i cant copy it, i would need to create new depth based on the top layer… otherwise it would be the same as not clearing the depth… right?

Just to clarify certain things, what exactly is broken for transparents? If depth clear is set for overlay, transparents should just overwrite on top, ignoring normal z tests.

If you want depth based PP on overlay while maintaining its “overlay” type rendering, I would suggest rendering PP twice, depth based effects on base camera (only depth based and no color grading/bloom stuff) and other effects on overlay.

Depth copying is just making a temporary render texture and just copying whatever from depth texture to the temp texture. I’m unsure if there are any examples out there but custom render feature will work.

Thanks, i have to have the depth based pp on the overlay cam because the skybox meshes must be covered by the terrain. I just learned that my water shader uses the dperh texture to create transparecy so that explains why its not working. I just cant figure out how to create a depth texture in a render feature and then also get the shader to use it. I cant figure out how to actually code that. Thanks for the help. Oh and i am using separate renderers for each camera.

1 Like