在 OpenGL 中使用多个颜色附件传输多重采样 FBO
我在 OpenGL 程序中有一个带有多个颜色附件的帧缓冲区对象,并且正在尝试将其升级为多重采样 FBO。
据我了解,多重采样 FBO 只能使用渲染缓冲区,特别是使用 glRenderbufferStorageMultisampleEXT 创建的缓冲区。如果我想要在纹理中渲染到该 FBO 上的某些内容,我需要创建第二个 FBO 及其附件的纹理,然后使用 glBlitFramebufferEXT
将多重采样的 FBO 位图传输到常规 FBO。
我见过的非常非常稀疏的例子都假设有单一颜色的附件。当我想要位块传送多个颜色附件时该怎么办?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自
EXT_framebuffer_blit
规范来自
arb_framebuffer_object
规范(取代EXT_ 版本)所以...很明显,您只能从每个位块传输的单个颜色缓冲区中进行解析。
要执行多个操作,您需要为每个缓冲区执行一次 Blit,为每个要进行 Blit 的缓冲区更改您的 READ_BUFFER,并选择绘制帧缓冲区对应的绘制缓冲区。
From the
EXT_framebuffer_blit
specificationFrom the
arb_framebuffer_object
specification (which superscedes the EXT_ version)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.您可以创建一个新的 Fbo,并将插槽 1 中的渲染缓冲区分配给插槽 0 处的它。然后绑定以进行读取,并从该位置位块传输到最终目标 Fbx。
即,可以纯粹为了绑定由另一个 Fbo 写入的现有渲染缓冲区而创建 Fbo。 Fbo 实际上并不拥有连接到它的缓冲区,因此多个 Fbx 可以绑定到相同的纹理/渲染缓冲区(尽管不是同时)。
// 渲染到Fbo0
Fbo0 : [ColorBuffer0, ColorBuffer1, DethBuffer]
// 在 slot 0 处绑定另一个 fbo 与 ColorBuffer1 进行读取
Fbo1 : [ColorBuffer1]
// blit Fbo0 ColorBuffer0 > Fbo2纹理0
Fbo0 : [ColorBuffer0, ColorBuffer1, DethBuffer] => Fbo2 : [Texture0]
//blit Fbo1 ColorBuffer1 (绑定在 slot0) > Fbo3 纹理 1(绑定在 slot0)
Fbo1 : [ColorBuffer1] => Fbo3:[纹理1]
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]