Access to gl_InstanceID in WebGL 2 Instancing

点点圈 提交于 2019-12-13 00:34:06

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/44427286/access-to-gl-instanceid-in-webgl-2-instancing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!