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 5 of 5

Thread: FBO multiple color attachments and the depth attachment

  1. #1
    Advanced Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    586

    FBO multiple color attachments and the depth attachment

    I could write a small test app but hopefully someone knows:

    Just wondering if I have an FBO with multiple color attachments and render to them in sequence if they all share the depth attachment.

    Suppose I render a full screen quad at the near clip plane in one attachment and then switch to another attachment and render a cube further back. Should I expect that the cube will not render to the second attachment?

  2. #2
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    303
    Either you are confused with multiple attachments or I am with how you work with them but if you have multiple attachments at one FBO you draw to all of them at the same time, not in sequence. In case I didn't quite get how you want to use FBOs, please give us some (pseudo) code.

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    586
    Well, you certainly *can* draw to them in sequence. Perhaps it's a case of 'you shouldn't do that'. If I'm drawing to multiple attachments simultaneously then that makes sense. But I can set the draw buffer to be one attachment then draw something. Then, I can set the draw buffer to another attachment and draw something entirely different. Normally, when drawing to multiple attachments at the same time, you are drawing the same object.

    This may be unconventional:

    //pseudo code
    FBO.Bind()
    glDrawBuffer(GL_COLOR_ATTACHMENT0);
    Sphere.Render();
    //at this point I have updated the DEPTH_ATTACHMENT with the sphere.
    glDrawBuffer(GL_COLOR_ATTACHMENT1);
    Cube.Render();

    So, I've rendered a sphere to the first color attachment and a cube to the second. Is there any contention with the depth buffer at this point? I would imagine there has to be.

    This is probably a case of doing something stupid that shouldn't be done.

  4. #4
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    303
    It should have the same state it had after drawing the first object. The result in attachment1 should be the same as drawing the sphere with color write off and then drawing the cube.

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    586
    That's what I thought should happen.

    Cheers.

Posting Permissions

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