Page 1 of 1
Is it possible to create CubeImage arrays?
Posted: Sat Sep 16, 2023 3:21 am
by bombquake
If I run
Code: Select all
local cubemap_array = love.graphics.newCanvas(1024,1024,10,{type="cube",format="depth16",readable=true})
print(cubemap_array:getTextureType())
print(cubemap_array:getLayerCount())
I get
there's only one layer, are cubeimage arrays supported?
Re: Is it possible to create CubeImage arrays?
Posted: Sat Sep 16, 2023 12:08 pm
by pgimeno
TextureType only lets you specify one of
array or
cube or the others, so no, you can't have a Cube Array as you can't specify both at the same time.
Also,
Texture:getLayerCount returns 1 for anything that isn't an array, so the result you're getting is expected.
Re: Is it possible to create CubeImage arrays?
Posted: Sat Sep 16, 2023 4:48 pm
by bombquake
I see thank you. I wanted to use them because I have several cubemaps I'm using inside my shader for omnidirectional shadow mapping and the compiler doesn't support sampler variable indexing. My current solution is to hard-code going through an array of them (below they're in in point_light_shadow_maps[]) so only constants are used for indexing
Code: Select all
// .\shader\vertex.glsl
#define DO_POINT_LIGHT(i)\\
if (u_point_light_count > i){\\
if (point_light_has_shadow_map[i])\\
{light += calc_point_light_col_shadow(i, frag_normal, i, point_bias, point_light_shadow_maps[i]);}\\
else\\
{light += calc_point_light_col(i, frag_normal);}}
float point_bias = 1.35;
DO_POINT_LIGHT(0);
DO_POINT_LIGHT(1);
DO_POINT_LIGHT(2);
DO_POINT_LIGHT(3);
DO_POINT_LIGHT(4);
DO_POINT_LIGHT(5);
DO_POINT_LIGHT(6);
DO_POINT_LIGHT(7);
DO_POINT_LIGHT(8);
It feels more like a hack than a solution; after doing some profiling the bottlenecks are elsewhere in the program but still, if anyone has any ideas for better ways this could be done I'd love to hear it