PDA

View Full Version : Texture as Depth-Buffer with default Framebuffer



Michael Nischt
10-05-2010, 10:17 AM
Hi all,

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 and best regards,
Michael

skynet
10-05-2010, 10:25 AM
Why don't you just complete the image in the offscreen buffer and then finally blit it into the window framebuffer?

Michael Nischt
10-05-2010, 03:13 PM
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.

Michael Nischt
10-05-2010, 03:47 PM
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.

Alfonse Reinheart
10-05-2010, 04:27 PM
Please correct me if I am wrong, but what I found out so far is that this is not possible in OpenGL

You are correct; you cannot bind images to the default framebuffer.

Michael Nischt
10-05-2010, 11:10 PM
Alfonse, thanks for confirming!