I am trying to do instancing in WebGL 2. I want to use the built-in variable gl_InstanceID
to index into a uniform float array.
I get the following error:
glDrawElementsInstancedANGLE: attempt to draw with all attributes having non-zero divisors
Is the only instancing allowed in WebGL 2 instancing with vertex attributes (instanced arrays)?
Also, is the spec the only definitive place to find out about these capabilities?
The spec says it's based on the OpenGL ES 3.0 spec
The remaining sections of this document are intended to be read in conjunction with the OpenGL ES 3.0 specification (3.0.4 at the time of this writing, available from the Khronos OpenGL ES API Registry). Unless otherwise specified, the behavior of each method is defined by the OpenGL ES 3.0 specification. This specification may diverge from OpenGL ES 3.0 in order to ensure interoperability or security, often defining areas that OpenGL ES 3.0 leaves implementation-defined. These differences are summarized in the Differences Between WebGL and OpenGL ES 3.0 section.
Unfortunately it looks like they forgot to specify that at least one attribute must have a non-zero divisor which is different from OpenGL ES 3.0. I filed a bug
The part that needs to be added is
INVALID_OPERATION is generated by DrawArraysInstanced or
DrawElementsInstanced if there is not at least one enabled
vertex attribute array that has a divisor
of zero and is bound to an
active generic attribute value in the program used for the draw command.