我读到在分层渲染中,我们创建了一个 2D 纹理数组(GL_TEXTURE_2D_ARRAY):
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D_ARRAY, TextureColorbufferName);
glTexParameteri(....
glTexImage3D(...
并可以将其附加到 FBO:
glGenFramebuffers(1, &FramebufferName);
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, TextureColorbufferName, 0);
我发现在视觉上难以理解的是如何将一层纹理绑定到 FBO 中的单一颜色附着点?颜色附件 0 (或任何 GL_COLOR_ATTACHMENTi )本身不是一个“图像”吗?
更详细地说:
在阅读纹理数组之前,这是我对 FBOS 的理解
+--------------+
+-----------+| FBO object ++--------------------------------------------+
| | +---------------------+ |
| +--------------+ | |
| + | |
| | | |
| | | |
v v v v
+-----------------+ +-----------------+ +-----------------+ +------------------+
|color attachment | |color attachment | |depth attachment | |stencil attachment|
| 0 | | 1 | | | | |
+-----------------+ +-----------------+ +-----------------+ +------------------+
(this too)
(this is actually (this is also a (this too)
one texture or texture of renderbuffer)
one renderbuffer)
但是在阅读了纹理数组之后,真的是这样吗?
+--------------+
+-----------+| FBO object ++--------------------------------------------+
| | +---------------------+ |
| +--------------+ | |
| + | |
| | | |
| | | |
v v v v
+-----------------+ +-----------------+ +-----------------+ +------------------+
|color attachment | |color attachment | |depth attachment | |stencil attachment|
| 0 | | 1 | | | | |
+-----+--+------+-+ +-----------------+ +-----------------+ +------------------+
| | |
| | v+
| v+ +----------------------------------+
| +--------->+ v
v | +
+----------------+ +---v-------------+ |
| | | | +---v------------+
|texture array[0]| |texture array[1] | |texture array[n]|
| | | | | |
| | | | | |
| | | | | |
+----------------+ +-----------------+ +----------------+
即每个附件本身是各种纹理的集合吗?
我很难想象一种颜色的附着点如何映射到多个纹理。
如果我从 1 个 FBO(绑定到 texture_2d_array)到另一个(绑定到 texture_2d)会发生什么