How can I access the default depth buffer from a fragment shader?

750 views Asked by At

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

0

There are 0 answers