So I want to do something like this:
const vec3 COLOR_MASKS[ 8 ] = { vec3( 0.0, 0.0, 0.0 ),
vec3( 0.5, 0.5, 0.5 ),
vec3( 1.0, 0.5, 0.5 ),
vec3( 0.5, 1.0, 0.5 ),
vec3( 0.5, 0.5, 1.0 ),
vec3( 0.5, 1.0, 1.0 ),
vec3( 1.0, 0.5, 1.0 ),
vec3( 1.0, 1.0, 0.5 ) };
color = COLOR_MASKS[index];
for a shader debugging tool (not for performance) – index being an int computed in the shader.
But the compiler says no way:
frag.glsl: error C7516: OpenGL does not allow constant arrays
frag.glsl: error C7549: OpenGL does not allow C style initializers
So what’s the GLSL paradigm for this? I’d rather not have to do the silly/verbose/less readable:
if val == 0 then
val2 = 123
else if val == 1 then
val2 = 456
...
approach.
Thanks.