I wonder if it is possible to use a texture as depth-buffer while rendering to the default framebuffer (GL_BACK)?
My problem is that I have a deferred rendering architecture and want to draw (semi-)transparent objects in a forward rendering pass on top.
Currently, I am rendering the opaque objects again with a glColorMask in the final forward pass. However, I already have the nearest depth values already in a texture.
An improvment is to render a fullscreen quad with the depth-texture and write the values to gl_FragDepth. Yet, I hope there is a better solution by simple ‘attaching’ the depth-texture to the default framebuffer. Is there one?
Thanks for the reply, but I don’t use an additional offscreen buffer for the the final color.
I only generate a single framebuffer object with textures for depth, normal and material data. Then for each frame a 1. pass renders to this as target and afterwards everything gets blended into the default framebuffer.
Please correct me if I am wrong, but what I found out so far is that this is not possible in OpenGL (although it is in Direct3D).
However, glBlitFramebuffer does a super fast copy (from the framebuffer depth-texture to the default depth-buffer), which seems to be the best workaround.