Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: problems with sharing depth buffer in FBO

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2010
    Posts
    2

    problems with sharing depth buffer in FBO

    Hi guys,
    I encounter a problem when using FBO in deferred shading system, my rendering pipeline is like this:
    1) render the scene into GBuffers using MRT;
    2) calculate sky lighting in screen space and output to a color texture;
    3) output color texture to main frame buffer;
    The problem is I wanna step 2 share depth buffer with step 1, so the calculation in step 2 only happen on pixels that is useful.
    I tried create render buffer in step 1 and bind it in the FBO create in step 2 (using glFramebufferRenderbuffer), but the result is not as excepted, the depth test is not correct in step 2 and no pixel be drawn.
    Anyone has done this before? or is any other way to share depth buffers among FBOs or FBO & Main FrameBuffer? any suggestion will be appreciated.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    892

    Re: problems with sharing depth buffer in FBO

    You don't need a renderbuffer for that. Create a depth texture and simply attach it to both FBOs. That's what I'm doing in my light pre-pass renderer and it works well(actually 3 FBOs share the same depth attachmant in my implementation).

    The only thing to make sure is that the order of operations is well defined to rule out side effects.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2010
    Posts
    2

    Re: problems with sharing depth buffer in FBO

    Problem found! I forget to change the depthfunc after step 2 rendering, so another frame begin with the wrong depth func and nothing draw at the beginning.
    Both renderbuffer and depth texture could be used among FBOs, and thanks thokra.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •