When drawing with gl.disableVertexAttribArray(0)
, Firefox (just like other browsers, they say) issues this warning:
WebGL warning: drawElementsInstanced: Drawing without vertex attrib 0 array enabled forces the browser to do expensive emulation work when running on desktop OpenGL platforms, for example on Mac. It is preferable to always draw with vertex attrib 0 array enabled, by using bindAttribLocation to bind some always-used attribute to location 0.
I know this. I know it is considered good practices to not disable 0. I do know it's written everywhere.
Yet, it's funny, it's exactly what I want. In my shader I have a 3D attribute and another 2D one to draw a 2D marker in window coordinates around a 3D point:
gl_Position = doSomething(aPosition) + vec4(aDelta, 0.0, 0.0);
And sometimes I just want aDelta
constant and aPosition
varying and sometimes the other way around. I specifically don't want to link the same program twice (to bind attributes to different locations), or have two different shaders, as the rest of the functionality is shared and either would be a waste.
I am aware of the performance hit, but it just works that way. Simulation or not, the result is correct and per spec. It's a simple function that draws just a few vertices at a time. Any other way would be "expensive emulation" on my side. Can I explain this to Firefox, so that it won't flood my console (this warning alone takes half of all the usual space!) and if I ever distribute this, my users won't think I'm inept to disregard a warning?