OpenGL 分层渲染和渲染缓冲区

OpenGL Layered Rendering & Renderbuffer

为什么在分层帧缓冲区上使用渲染缓冲区不起作用? 我读到如果你想要深度值你必须使用额外的纹理。 是这样吗?或者还有其他使用渲染缓冲区的选项吗?

对,就是这样。为什么?好吧,简单的答案是它是这样定义的。来自 OpenGL 规范文档,第 "Whole Framebuffer Completeness":

部分

If any framebuffer attachment is layered, all populated attachments must be layered. Additionally, all populated color attachments must be from textures of the same target (three-dimensional, one- or two-dimensional array, cube map, or cube map array textures).

由于没有分层渲染缓冲区,您不能将它们用于分层渲染。