I was able to get instancing working with OpenGL and created a grid of sprites (different positions)….but same art (sprite frame). I'm only passing the sprite coordinate matrix once as a uniform. Which is okay for none instanced sprites.
How would I go about passing different sprite coordinate matrices for each instance? Can or should I pass the matrices as an attribute the same way I did for the vec3 positions of the instances? I'm really confused about this :( Would anybody have any suggestions you're willing to share with me?
---------------------------------------------------------------
Extra Info on how I render my spritesheet frames:
In order to get the right frame from my sprite sheet I do the following from the CPU:
matrix = mat4(1.0f);
matrix = translate(matrix, vec3(frame.x, frame.y, layer));
matrix = scale(matrix, vec3(frame.width, frame.height, 1.0f));
Then on the GPU I do the following:
uv = (sprite_matrix * vec4(uv_coord, 0, 1)).xy;
The sprite matrix is a uniform and the uv_coord is of course an attribute. The resulting uv vec2 is then passed to the fragment shader. This works very nicely so far.