View Full Version : Referencing arrays in Fragment Programs

03-31-2006, 09:09 AM
I am trying to reference an array that is passed in as a uniform parameter with another uniform parameter in a fragment shader, like this:

uniform mat4 matrices[20];
uniform int MatIndex;

void main(void)
vec4 result = somevector * matrices[MatIndex];
}But the linker complains that the indexing must use a compile-time constant.......

is that true for fragment programs and not for vertex programs? I do not understand why this could be a fragment program limitation.

please help.

03-31-2006, 02:02 PM
Most (all?) hardware does not support indexing into constants in the fragment shader. If you need to support this, store your constants in a small texture setup to use GL_NEAREST filtering and fetch your data from the texture with the appropriate texture coordinates.