in int gl_VertexID causing error with three.js
glsl, three.js, webgl
Solution
As far as I'm aware, in WebGL you can't access built-in vertex indices.
However you should be able emulate this by providing your own custom attribute stream, set to values that would be equivalent to such built-in index stream.
In three.js there are no integer custom attributes implemented yet, so you would need to use float attribute.
Check "displacement" attribute in this example:
http://mrdoob.github.com/three.js/examples/webgl_custom_attributes.html
Problem
I've been having trouble with the gl_VertexID built in vertex index, passed using `in`, to work with Three.js I'm not sure why, as the documentation says it works in all versions of OpenGL http://www.opengl.org/sdk/docs/manglsl/xhtml/gl_VertexID.xml I'm using this vertex shader: ``` uniform int freqData[64]; uniform int fftSize; in int gl_VertexID; void main() { vec3 norm = normalize(position); int modFFT = mod(gl_VertexID, fftSize); vec3 newPosition = norm * float(freqData[modFFT]); gl_Position = projectionMatrix * modelViewMatrix * vec4( newPosition, 1.0 ); } ``` The error I receive is: `ERROR: 0:68: 'in' : syntax error` It seems to have a problem with the `in` declaration, and it doesn't complain about anything else (the error console is able to detect multiple compilation errors). I very much appreciate your help, I'm working with yesterday's Three.js build.