开发者

Blitting multisampled FBO with multiple color attachments in OpenGL

I have a frame buffer object in an OpenGL program with multiple colour attachments, and am trying to upgrade it to a multisampled FBO.

As I understand it, a multisampled FBO is only able to use render buffers, specifically ones created using glRenderbufferStorageMultisampleEXT. If I want something rendered to this FBO in a texture, I need to create a second FBO with textures for its attachments, then blit the multisampled FBO to the regular FBO using glBlitFramebufferEXT.

The very, very sparse examples I've seen assume a single colour attachment. What do I 开发者_运维问答do when I want to blit multiple colour attachments?


From the EXT_framebuffer_blit specification

12) Should we add support for multiple ReadBuffers, so that multiple color buffers may be copied with a single call to BlitFramebuffer?

Resolved: No, we considered this but the behavior is awkward to define and the functionality is of limited use.

From the arb_framebuffer_object specification (which superscedes the EXT_ version)

When the color buffer is transferred, values are taken from the read buffer of the read framebuffer and written to each of the draw buffers of the draw framebuffer, just as with CopyPixels.

So... It's pretty clear that you resolve only from a single color buffer per blit.

To do multiple ones, you need to do a Blit for each buffer, changing your READ_BUFFER for each buffer you want to blit, and select the corresponding draw buffer of the draw framebuffer.


You can create a new Fbo and assign the renderbuffer in slot 1 to it at slot 0. Then bind for reading and blit from that to your final destination Fbx.

i.e. An Fbo can be created purely for binding an existing renderbuffer that was written to by another Fbo. An Fbo doesn't actually own the buffers that are connected to it so multiple Fbx can be bound to the same textures/renderbuffers(though not at the same time).

// Render to Fbo0 Fbo0 : [ColorBuffer0, ColorBuffer1, DethBuffer]

// Bind another fbo with ColorBuffer1 at slot 0 for reading Fbo1 : [ColorBuffer1]

// blit Fbo0 ColorBuffer0 > Fbo2 Texture0 Fbo0 : [ColorBuffer0, ColorBuffer1, DethBuffer] => Fbo2 : [Texture0]

//blit Fbo1 ColorBuffer1 (bound at slot0) > Fbo3 Texture1 (bound at slot0) Fbo1 : [ColorBuffer1] => Fbo3 : [Texture1]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜