This code is not JavaScript, but GLSL . This is the language used to write programs that run on your GPU. It does not have the var keyword. Instead of declaring variables in GLSL, you need to put a type in front of them
vec3 m = normalize(fragmentNormal); vec3 l = normalize(fragmentLight); vec3 v = normalize(fragmentView); vec3 h = normalize(l + v); vec3 d = max(l * m , 0.0); vec3 s = pow(max(h * m, 0.0), vec3(10));
I'm not sure what you are trying to do above, but all your equations produce vec3 .
Also GLSL 1.00 es is strictly type specific. You cannot use vec3 with integers. You must use floating point numbers. 0.0 instead of 0 . The last line does not have a pow function that takes vec3 on the left and one value on the right, so vec3(10) takes an integer 10 and discards it on vec3 . This is the same as vec3(10, 10, 10) .
GLSL also does not have a Math. library Math. . Built-in functions are global.
source share