0
\$\begingroup\$

I want to have both Point Lights, aswell as Spot Lights. For the Point Lights I have a TextureCubeArray and for the Spot Lights I have a Texture2DArray. Is it possible to combine these two into a single Texture2DArray and treat the Point Light Shadow Maps as Cubemaps, and treat the SpotLight shadow maps as single textures?
I would like to bind only one array instead of multiple ones.

\$\endgroup\$
1
  • \$\begingroup\$ Your code for reading a value from each of these texture types will be different, so I don't see a benefit of storing them interleaved in a single array, when instead you could have one array for one code path, and a second array for the other code path. \$\endgroup\$
    – DMGregory
    Aug 27, 2020 at 11:32

2 Answers 2

1
\$\begingroup\$

To attempt to give this question some closure:

No, you cannot mix 2D and cubemap textures in a single array.

Doing so would not give you any benefit, since you would still need a branch in the code that reads from those textures: one needs to sample with a 2D UV coordinate, the other with a 3D direction vector.

So you might as well have two arrays, and sample from one array in the first branch, and the other array in the second branch. You could use the sign of your index variable to determine which branch to take, without needing an additional "cube or spot?" variable as input to the shader.

Or, quite likely more efficiently, you could render your lights in two passes: one pass for spotlights and a second for cubemaps, using a dedicated shader for each. Your shader stays simpler and branch-free, and you can apply different culling rules or other optimizations to each pass.

\$\endgroup\$
0
\$\begingroup\$

Use atlas for shadowmapss and combine cubemaps manually in shader. Also, this approach will allow to use variable shadow map resolution for close and distant lights.

\$\endgroup\$
1
  • \$\begingroup\$ How does combining cubemaps manually in a shader work with seamless cubemapping? \$\endgroup\$ Aug 26, 2021 at 21:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .