2

I am going to port DirectX code to OpenGL and need to choose the right OpenGL version. What I want to do might not even be possible according to what I already read online.

As I understand it (I might be wrong though), I can use the default depth buffer as a pixel shader resource in DirectX 10 [1]. That is useful for deferred lighting. In a first pass I would draw the meshes and the depth buffer would be filled. During the post processing I could then use the depth buffer information. I would not have to use multiple render targets and could save some memory and bandwidth that way.

Is the only way to achieve this in any OpenGL version to use an FBO and blitting [2, 3]?

[1] http://bitwisegames.wordpress.com/2011/03/25/getting-direct-access-to-the-depthbuffer-in-directx10/

[2] http://www.gamedev.net/topic/578084-depth-buffer-and-deferred-rendering/

[3] http://www.opengl.org/discussion_boards/showthread.php/180782-Binding-to-a-different-depth-buffer

lochotzke
  • 181
  • 1
  • 4
  • You don't. The only way you can access framebuffer components from a fragment shader is if you sample textures. The only way to sample the depth using a texture is if you draw into an FBO and attach a depth texture. You should consider using a textured quad to output your MRT pass to the default framebuffer instead of `glBlitFramebuffer (...)`, it is possible to do but `glBlitFramebuffer (...)` is primarily useful for renderbuffer -> renderbuffer/default framebuffer copy operations. You gain a lot more post-processing potential by using a textured quad, and it is generally quicker. – Andon M. Coleman Dec 04 '13 at 22:42

0 Answers0