It could save me to create another framebuff for opaque objects, since I render opaque objects to default frame buffer I need to default depth buffer for second pass.
There are three passes (see page):
- 3D opaque surfaces to a primary framebuffer
- 3D transparency accumulation to an off-screen framebuffer
- 2D compositing transparency over the primary framebuffer ( using alpha blending )
For transparency pass it says "Test against the depth buffer, but do not write to it or clear it.". So it seems I don't need to write depth buffer in transparency pass, I only need to read opaque's one to test depth which is default depth buffer.
Binding default depth buffer ( after opaque pass ) to transparency framebuffer would be nice but I'm not sure if it is possible or not.
As alternative I created a depth buffer for off-screen framebuffer (transparency) which is GL_DEPTH_COMPONENT24, it seems glBlitFramebuffer offer copying a buffer to another frame buffer. But what if formats mismatch? 32-bit vs 24-bit
Another alternative is that creating a framebuffer for opaque surfaces too. Then since I have depth buffer ID, I can bind it to another framebuffer I guess, then set depth mask to false. But I need to create another color buffer / color attachment and depth buffer for this framebuffer. I don't know which one is faster copying default depth using glBlitFramebuffer or this method.