Encountered an issue with Three.js where using an array with a non-constant index resulted in the error message:
'[]' : Index expression must be constant
When working with the following fragment shader:
precision mediump float;
varying vec2 vUV;
uniform vec2 screenResolution;
vec4 colors[2];
void main(void) {
vec2 uv = gl_FragCoord.xy / screenResolution.xy;
colors[0] = vec4(0.0);
colors[1] = vec4(1.0);
int index = int(floor(uv.y * 1.9));
gl_FragColor = colors[index];
}
This error did not occur when using Babylon.js.
Is it now possible to use non-constant indices for arrays in newer versions of GLSL ES
, even though it was not supported before?
How can I determine the GLSL versions utilized by Three.js and Babylon.js?