如何在视觉上定义将纹理数组附加到FBO的颜色附加点? [英] How to you define attaching a texture array to a FBO's color attachment point visually?
问题描述
我了解到,在分层渲染中,我们创建了2D纹理数组(GL_TEXTURE_2D_ARRAY):
I read that in layered rendering, we create a 2D texture array (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中的任何一个)本身不是单个图像"吗?
What i find hard to understand visually is how can a layer of textures be bound to a single color attachment point in FBO? Isnt color attachment 0 (or any of GL_COLOR_ATTACHMENTi ) a single "image" in themselves?
详细信息:
在阅读纹理阵列之前,这是我对FBOS的理解
Before reading about texture arrays, this was my understanding of 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)
但是在了解了纹理阵列之后,这真的是吗?
But after reading about texture arrays, is this how it really is?
+--------------+
+-----------+| 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]|
| | | | | |
| | | | | |
| | | | | |
+----------------+ +-----------------+ +----------------+
即每个附件本身是各种纹理的集合吗?
i.e is each attachment itself a collection of various textures?
这对我来说很难想象1个颜色附着点如何映射到多个纹理.
This is hard for me to visualize how 1 color attachment point maps to multiple textures.
如果我从1个FBO(一个绑定到texture_2d_array)到另一个(一个绑定到texture_2d),会发生什么情况
What happens if i blit from 1 FBO (one that is bound to texture_2d_array) to another(one that is bound to texture_2d)
推荐答案
纹理是图像的集合.您不将纹理附加到FBO附加点;而是将纹理附加到FBO附加点.您可以在纹理中 中将图像附加到FBO附加点.
A texture is a collection of images. You do not attach a texture to an FBO attachment point; you attach an image within the texture to an FBO attachment point.
因此,您绝不会将多个纹理附加到一个附加点.
So at no point do you attach multiple textures to a single attachment point.
阵列纹理只是在mipmap级别内存储图像阵列的纹理.非数组2D纹理在每个mipmap级别仅存储一个图像.立方体贴图每个mipmap存储6张图像.数组纹理可为每个mipmap存储用户提供的图像数量.
Array textures are just textures that store an array of images within a mipmap level. A non array 2D texture only stores one image per mipmap level. A cubemap stores 6 images per mipmap. An array texture stores a user-provided number of images per mipmap.
但是,您可以将分层图像附加到附加点. 阵列纹理的mipmap级别是分层图像,还有其他一些东西.
However, you can attach a layered image to an attachment point. A mipmap level of an array texture is a layered image, as are several other things.
通过分层图像构建的FBO可以通过以下方式用于分层渲染几何着色器.这使GS可以将特定的原始输出通过管道传递到分层FBO内的特定层索引.
An FBO that is built from layered images can be used for layered rendering via a Geometry Shader. This allows the GS to pipe a particular primitive output to a specific layer index within the layered FBO.
如何可视化这取决于您.
How you visualize this is up to you.
这篇关于如何在视觉上定义将纹理数组附加到FBO的颜色附加点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!