【问题标题】:Binding the same renderbuffer to multiple FBOs将同一个渲染缓冲区绑定到多个 FBO
【发布时间】:2013-08-18 11:09:31
【问题描述】:

我的 opengl 场景有两个通道 - 一个渲染整个场景(颜色和深度),第二个只渲染一些场景对象,它需要第一个通道的深度缓冲区。

是否可以使用两个帧缓冲区对象 FBO1 和 FBO2,并将相同深度的渲染缓冲区绑定到它们?一个伪代码是:

// ---------- Initialization ---------- 
// create 'FBO1'
// create render buffer 'RB'
// bind RB to FBO1
// bind TEXTURE1 to FBO1 for color rendering

// create FBO2
// bind RB to FBO2
// bind TEXTURE2 to FBO2 for color rendering

// ---------- Rendering frame---------- 
// bind FBO1
// render entire scene with depth writing enabled
// bind FB2
// render some objects again with depth mask GL_EQUAL

结果应该是 TEXTURE2 只包含那些未被第一遍渲染的其他对象遮挡的对象部分。

【问题讨论】:

    标签: opengl rendering opengl-es-2.0


    【解决方案1】:

    是否可以使用两个帧缓冲区对象 FBO1 和 FBO2,并将相同的深度渲染缓冲区绑定到它们?

    是的,这是完全可能的。但是,单个渲染缓冲区或纹理不得同时成为给定 FBO 中多个附件中的渲染目标。

    【讨论】:

    • @NicolBolas:当然。我编辑了我的答案以明确(呃)。
    • 那么我可以使用其中一个 FBO 读取深度缓冲区,同时将另一个用作渲染目标并写入它吗?
    猜你喜欢
    • 1970-01-01
    • 2015-06-07
    • 1970-01-01
    • 1970-01-01
    • 2017-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    相关资源
    最近更新 更多