Search code examples
glslwebglvertex-shaderglsles

WebGL `uniform uint` Causes Syntax Error


I am using Google Chrome Version 59.0.3071.115 (Official Build) (64-bit) on Windows 10.

I have a vertex shader that looks like so:

attribute vec3 aPosition;
attribute vec2 aTextureCoordinate;

uniform uint uLayer;
uniform vec2 uLocation;

varying highp vec2 vTextureCoordinate;

void main(void)
{
  gl_Position = vec4(aPosition + vec3(uLocation, 0.0), 1.0);
  vTextureCoordinate = aTextureCoordinate;
}

A prior version did not have line four (uniform unit uLayer;), and it compiled fine. Adding in that line causes an ERROR: 0:5: 'uLayer' : syntax error. As far as I can tell, there is nothing wrong with this line syntactically, and I cannot find anything stating uniform uint is not valid in a vertex shader. Is there something I am missing here?


Solution

  • WebGL 1 uses GLSL 100, which does not support uint. WebGL 2 uses GLSL 300 which adds uint.