If I bind individual layers of a texture array (GL_TEXTURE_2D_ARRAY
) to different color attachment points (e.g I am binding the 4 layers of texture array 'textureName' to color attachments 0,1,2 and 3):
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + 0, textureName, 0, 0);
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + 1, textureName, 0, 1);
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + 2, textureName, 0, 2);
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + 3, textureName, 0, 3);
And in the geometry shader , I use gl_Layer
to assign vertices to different layers. (I am just duplicating geometry)
2 Followup questions:
Case 1: My Fragment shader writes to only first color buffer. (location = 0.)
What do the 4 layers of texture array contain at end of the program execution? Did geometry duplication occur (because of using gl_Layer
) or the last 3 textures are blank(because I did not write to other color buffers in fragment shader)?
Case 2: I write to all 4 color buffers in the fragment shader (location = 0, 1, 2, 3)
What do the 4 layers of texture array contain at end of the program execution?
By these 2 cases, I am trying to understand if layered rendering has any impact on multiple render targets.