Creating two cubemaps a the same time

This is related to this other posting but not exactly.

I want to generate two cubemaps that are collecting different information from the same scene.

The first cubemap collects depth information from the camera.
The second cubemap contains the identifier of each object that I have on a scene.

I am able to generate both cubemaps separately. I would like to combine them together instead of running them one after the other. I have a few specific questions:

Can I attach both cubemaps to the same framebuffer?? (I imagine you can???)
If both cubemaps have the same specs (same size, format) can I combine them into a cube_array? What is the proper syntax for that?

Thank you :slight_smile:

You could do that, but it would be unhelpful.

When using a cubemap as a rendering target, cubemaps work like array textures. If you attach the entire cubemap to an FBO attachment point, then that FBO becomes a layered framebuffer. Each triangle renders to a single face of the cubemap. That’s fine.

However, if you attach a cubemap array to an attachment point… the same thing happens. Cubemap arrays function as a single layered image, just with 12 layer-faces instead of 6. So you can render a triangle to a face of one cubemap, or a face of a different cubemap, but a single triangle cannot write to both at the same time.

If you do want to write to both, then you want to attach the cubemaps to different attachment points. You technically could still array the cubemaps together, but you cannot directly attach part of an array to an FBO attachment point. Therefore, you would have to use view textures to create separate cubemaps that you attach to the FBO. It’s probably not worth it.

Thank you @Alfonse_Reinheart for the explanation. This is not something I would have been able to figure out!