4

I'm trying to implement Weighted, Blended Order-Independent Transparency

There are three passes:

  1. 3D opaque surfaces to a primary framebuffer
  2. 3D transparency accumulation to an off-screen framebuffer
  3. 2D compositing transparency over the primary framebuffer

I need to test transparent objects against default depth buffer. I created a framebuff for transparency pass and also created a depth buffer for maybe I can copy default depth to this buffer if this is the only way. But I don't know how to do that because I created depth buffer with GL_DEPTH_COMPONENT24 but I don't know default depth format.

Is it possible to bind default framebuffer's depth buffer to another framebuffer? If not, how can I copy default depth to another depth buff, or what is best way to do this?

recp
  • 185
  • 1
  • 9

1 Answers1

3

Is it possible to bind default framebuffer's depth buffer to another framebuffer?

First, you "attach" images to framebuffers. You "bind" objects to the context; you "attach" objects to other objects.

Second, no, you cannot attach images of the default framebuffer to anything.

If not, how can I copy default depth to another depth buff, or what is best way to do this?

You render to your own depth buffer entirely. Just copy/render the image data out to the default framebuffer when its time to display it.

Nicol Bolas
  • 9,762
  • 18
  • 25
  • what about glBlitFramebuffer? Can't I copy default framebuffer's images or depth to another framebuffer with it? – recp Feb 07 '18 at 18:03
  • 1
    @recp: Yes, you could. Or you could just render to your own image and not have to do a copy. Why pick the slower option? – Nicol Bolas Feb 07 '18 at 20:15
  • "Why pick the slower option?" maybe this is what I was looking for. I don't know which one is faster so I tried to save texture space. As a solution I will render opaque objects to another framebuff and share its depth buffer with transparency framebuff, this seems better way and fits with your answer I guess – recp Feb 07 '18 at 20:18