Single-pass render to six depth cubemap faces without geometry shader

Hi, I am having trouble finding information on how this is done. glDrawBuffers seems to only concern color textures. I was pretty sure it was possible to render to six depth cubemap faces in one pass, for point shadow maps. Is that correct? Can you point me in the right direction? Thank you.

I was able to create an array texture with 6 layers and attach that to an FBO, but how do I tell OpenGL to render to all six layers at once? Does it automatically?

You can’t. Not in un-extended OpenGL.

Layered rendering is the ability to specify which layer in a layered framebuffer a particular primitve goes to. Since this is a per-primitive operation, it naturally is a function of the geometry shader. For rendering a depth cubemap, you need to turn 1 triangle into 6. This again is a function that the GS can do, preferably through instanced geometry shaders, where you use the instance index to index into your array of view/projection matrices for the 6 faces of the cube.

Now conceptually, you could do this without a GS through regular instanced rendering. You can access your array of view/projection matrices with the instance index and do the transform appropriately. All of the primitives produced by a single instance would go to the same layer. The problem is that the VS just doesn’t have a way to specify the layer index for its outputs.

The extensions AMD_vertex_shader_layer and *_viewport_index allow a vertex shader to specify the layer and viewport index, thereby allowing them to do layered rendering without a GS. These extensions are reasonably widely supported, by NVIDIA and Intel despite the vendor-specific extension.

But they were never promoted to core OpenGL, so you have to rely on extensions if you want to avoid geometry shaders.

What about this extension? This looks a lot like multi-view rendering in Vulkan:

Considering that the minimum requirement is 2 layers and you need 6, that’s not a great way to handle this. I also suspect that any hardware that supports OVR_multiview probably also supports the two extensions I mentioned beforehand.

But it would probably work.

1 Like

32x is the limit on my GEForce 1080 :laughing: