If I'm doing instanced rendering and need to send one mat4 per instance to the vertex shader, which approach is likely to be faster for large numbers of instances?
- Using an instanced mat4 attribute (glVertexAttribDivisor) and sending the mat4s into the VBO each frame (glBufferData)
- Using an array of mat4 uniforms in a uniform block, updating the array every frame using a uniform buffer object and accessing the appropriate mat4 using gl_InstanceID as the array index
glVertexAttribDivisor
was designed to address, I'd expect option 1 to be more efficient. It's neater, too. – user269597glVertexAttribDivisor
is a perfect fit for large number of instances who's positions don't change (e.g. forest of trees), I think it's a closer call when their transforms have to be updated every frame. Setting uniforms might be quicker than updating a buffer. – GuyRT