Setting texture as depth

I have a deferred shading engine using FBOs that captures 3 “color” channels and a depth channel. Since the FBO rendering context claims the depth buffer rendered as its own, any rendering made post-deferred-shader cannot make use of the depth values (i.e. alpha geom, particles, FX, etc). Is there some way to replace the depth values in the default rendering context, from the texture captured by the FBO?

P.S. For the FBO, I have not actually allocated pixel data for any of my buffers, so I cannot use glDrawPixels.


I don’t think you can replace the DEFAULT context’s depth buffer with your own, but you can create an additional FBO and share the depth renderbuffer with it.

disable colour writes and draw a quad using the depth texture with depth test disabled…or am I missing something?

This will set the depth value of the texture to the depth buffer outside any FBO? I’ve never seen anything like this, is there an example that anybody knows of that demonstrates this?


This would be the simplest way, but only Nvidia has currently support for it.