Reputation: 2470
To implement Geometry instancing in OpenGL ES 2.0 I am considering passing mat4 as an attribute. Since attributes are per vertex data do I need to pass this same mat4, three times for each vertex of the same triangle(since modelview remains constant across vertices of the triangle).
That would amount to a lot of extra data sent to the GPU( 2 extra vertices*16 floats*(Number of triangles) amount of extra data).
Or should I be sending the mat4 only once per triangle?But how is that possible using attributes since attributes are defined as "per vertex" data?
Upvotes: 1
Views: 328
Reputation: 35943
There's no such thing as a 'per-triangle' attribute. If you want to send them as attributes, it's per vertex.
Another option would be to upload all matrices in a uniform array, and then just have an integer index per vertex which determines which matrix to lookup. That will reduce your streaming overhead by quite a bit.
Upvotes: 2