How to merge from several Depth buffers?


Guys,
I wanna do as what you can see in the picture above.

I have multiple gameObjects in the scene, and I want to render each of them to different depth buffers, and then merge infos from these depth buffers, and render the final color based on the merged depth buffer?

How can I do that? Or, is there any other way around of doing the same thing?

You could try to render them to a rendertexture with a depth shader and do your magic there.

But it’s actually more complicated than that… Actually I want to render something other info and decode into color buffer(cause it could be 32bit per pixel, and depth buffer only uses 24bits if I’m correct).

So different objects need to be rendered into different color buffer, and merge them together to one final color buffer.

Well, that sounds complex already, I just wanna do an image space penetration resolving thing… Maybe I need to learn more about advanced rendering techniques in Unity, but can’t find enough resources to learn.

there’s nothing stopping you from rendering depth into the colorbuffer though

As mentioned, just render each different depth buffer (or color buffer) to a render texture and and then add those textures to your shader. You can then do whatever you want with the values from each one of them (merge them however you like).