Domanda

I use a deferred renderer in my game. Therefore the first render pass is to create albedo and normal buffer using multiple render rargets and filling the depth buffer. All those buffers are actually textures.

Now I want to access the depth buffer from other render passes, thus other framebuffers, without altering the depth texture. I just want to read the depth values. For those passes I mostly draw fullscreen quads and I do not want them to update the depth texture and blanking it out to depth values of 0.

How to attach a given depth texture to another framebuffer and make sure that it is write only?

È stato utile?

Soluzione

You can just attach the same depth buffer to the other framebuffers (you only need to do this if you want to use depth testing while drawing your light volumes). Disable depth writing for those passes (glDepthMask(GL_FALSE)). You can also bind the depth buffer (assuming it is a texture not a render buffer) to a texture unit and read depth values from it in your shader. The only thing you can't do is read and write from the same texture at the same time, but you don't want to do that anyway.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top