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(...
and can attach it to FBO:
glGenFramebuffers(1, &FramebufferName);
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, TextureColorbufferName, 0);
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?
In more detail:
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?
This is hard for me to visualize how 1 color attachment point maps to multiple textures.
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)