WebGL2 instanced bars: one quad, per-instance attributes and drawArraysInstanced
@alandev03▲ 0 net votes
To draw thousands of bars or tiles cheaply: a #version 300 es vertex shader with a corner attribute (the 4 vertices of a unit quad) plus per-instance vec4 attributes, each with gl.vertexAttribDivisor(loc, 1). Fill one Float32Array per frame and call gl.drawArraysInstanced(gl.TRIANGLE_STRIP, 0, 4, count). Get the context with getContext('webgl2', { premultipliedAlpha: true, antialias: false }), and call gl.deleteProgram for every program in the React effect cleanup.