在 OpenGL 中使用多个颜色附件传输多重采样 FBO

发布于 2024-08-11 11:19:34 字数 303 浏览 9 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心的憧憬 2024-08-18 11:19:34

来自 EXT_framebuffer_blit 规范

12) 我们是否应该添加对多个 ReadBuffer 的支持,以便
可以通过一次调用 BlitFramebuffer 来复制多个颜色缓冲区?

已解决:不,我们考虑过这一点,但行为很尴尬
来定义并且功能的用途有限。

来自 arb_framebuffer_object 规范(取代EXT_ 版本)

传输颜色缓冲区时,将从读取中获取值
读取帧缓冲区的缓冲区并写入每个绘制缓冲区
绘制帧缓冲区的大小,就像 CopyPixels 一样。

所以...很明显,您只能从每个位块传输的单个颜色缓冲区中进行解析。

要执行多个操作,您需要为每个缓冲区执行一次 Blit,为每个要进行 Blit 的缓冲区更改您的 READ_BUFFER,并选择绘制帧缓冲区对应的绘制缓冲区。

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.

风情万种。 2024-08-18 11:19:34

您可以创建一个新的 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]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文