I'm having an issue trying to compile a fragment shader. I keep getting this error:
Uncaught Error: Fragment Shader Compiler Error: ERROR: 0:21: '[' :
array index for gl_FragData must be constant zero ERROR: 0:21: '[' :
array index for gl_FragData must be constant zero ERROR: 0:21: '[' :
array index for gl_FragData must be constant zero
This is the code:
#ifdef GL_EXT_draw_buffers
#extension GL_EXT_draw_buffers : require
#endif
#ifdef GL_ES
precision highp float;
#endif
void main() {
gl_FragData[0] = vec4(1.,2.,3.,4.);
gl_FragData[1] = vec4(1.,2.,3.,4.);
gl_FragData[2] = vec4(1.,2.,3.,4.);
gl_FragData[3] = vec4(1.,2.,3.,4.);
}
The whole setup works fine if I'm setting gl_FragColor
(with the 4 textures attached to the frame buffer), but trying to do the code above (indexing the buffers to output to) seems to not compile. I have seen this working fine in WebGL1 using extensions. I'm using WebGL2, so perhaps something is different in this context? (I'm trying it in the latest version of Chrome).