Binding the same renderbuffer to multiple FBOs
My opengl scene has two passes - one which renders the entire scene (color
and depth) and a second which renders only some scene objects, which needs
the depth buffer from the first pass.
Is it possible to use two framebuffer objects FBO1 and FBO2, and to bind
the same depth renderbuffer to both of them? A pseudo-code for that would
be:
// ---------- Initialization ---------- // create 'FBO1' // create render
buffer 'RB' // bind RB to FBO1 // bind TEXTURE1 to FBO1 for color
rendering
// create FBO2 // bind RB to FBO2 // bind TEXTURE2 to FBO2 for color
rendering
// ---------- Rendering frame---------- // bind FBO1 // render entire
scene with depth writing enabled // bind FB2 // render some objects again
with depth mask GL_EQUAL
The result should be that TEXTURE2 contains only those parts of the
objects which are not occluded by other objects rendered in the first
pass.
No comments:
Post a Comment