How to render to a subsection of a cubemap array?

Say I have a cubemap array and a shading program to render depth maps.

I want to iteratively render to a single cubemap in the cubemap array for each light.

In other words I want to select a subsection of the cube mapo array to which the shading rpogram will output it’s shading information.

What do you mean by “iteratively render”? If you’re rendering an object, how do you know which cubemaps in the array you want to render to? Are you trying to render to only one layer-face at a time, or to several array layers at once? Is the light a uniform value, or is it something that changes within the rendering call?

The general solution is “use layered rendering”, but the specifics differ based on the answers to the above.

You can either bind a single layer-face (i.e. one face of one cube map), or the entire cube map array. In the latter case the framebuffer will be layered and you’ll need a geometry shader which sets gl_Layer to select the layer-face.

If you bind individual layer-faces, you’ll need six draw calls per layer. If you bind the entire array as a layered framebuffer, you can potentially draw everything in one draw call using instanced rendering. In the latter case, you can either have one instance per layer-face (i.e. one for each light and axis) with a trivial geometry shader setting gl_Layer from gl_InstanceID, or one instance per layer and a more complex geometry shader which transforms and outputs each primitive to all of the faces which it intersects.