WebGL GLSL ” : syntax error
2 minute read.
GL::Shader::compile(): compilation of fragment shader 2 failed with the following message: ERROR: 1:1: '' : syntax error
Aparently WebGL shader compilers sometimes just deny you any information on what’s wrong with your shader code.
Potential Causes
To hopefully save some people some time, here are the code snippets that I know can cause this error:
Preprocessor Multiplication
#define A 1 #define B 2 uniform lowp vec4 array[A*B]; #ifdef NOT_DEFINED_SYMBOL // Not a problem if not evaluated uniform lowp vec4 array2[A*B]; #endif
Includes
#ifdef NOT_DEFINED_SYMBOL #include "Someother.glsl" #endif
Yes, includes are not supported in GLSL, but if you have your own system for that, make sure you don’t leave any traces of that. Even when it should not be evaluated, it may cause the above issue.