2
$\begingroup$

I am using layered rendering for all my light sources to avoid rendering multiple times. I have lightSourceCount many point lights and one sun, which is implemented as an orthographic light source (due to the large distance). The sun light should be implemented as cascaded shadow mapping (4 cascades), because I would like to render landscapes. The shadowmap resolution and format of the point lights and the cascaded shadow maps are equal.

Is it possible to define a GL_TEXTURE_2D_ARRAY with (lightSourceCount * 6 + 4) layers as shadow maps. Render the scenario using layered rendering to fill these shadow maps. And afterwards use the first lightSourceCount * 6 layeres as a GL_TEXTURE_CUBEMAP_ARRAY with lightSourceCount layers within GLSL to be able to use gvec4 texture(gsamplerCubeArray sampler, vec4 P, [float bias]); while the last 4 layers are able to be used with gvec4 texture(gsampler2DArray sampler, vec3 P, [float bias]);?

If yes, how can I do that? Can I just bind the GL_TEXTURE_2D_ARRAY as a GL_TEXTURE_CUBEMAP_ARRAY? And use the last 4 layers by binding the same Texture as GL_TEXTURE_2D_ARRAY and access the last 4 layers by using texture(gsampler2DArray sampler, vec3(uvCoordinate, lightSourceCount * 6 + currentTexture))?

$\endgroup$

1 Answer 1

2
$\begingroup$

You can use view textures to accomplish what you're talking about. You create a 2D array texture and give it the number of layers you want. This is the base texture.

You can then construct two restricted views of the base texture. The first is a cubemap array texture using layers 0 to lightSourceCount * 6. The second is a 2D array texture using layers lightSourceCount * 6 to lightSourceCount * 6 + 4.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.