I'm working on a game that has to render a large amount of cubes (voxels) with OpenGL. All cubes have the same geometry (so I can re-use the vertex position VBO) and a single sprite sheet texture is used for all of them. This means the texture coordinates will have to vary for the cubes, depending on which sprite to use. All six sides of a cube will use the same sprite (in other words, the same texture coordinates).
Now, what is the best strategy to approach this with a modern OpenGL renderer?
I came up with two possibilities:
Create as many VAOs as there are cube sprites in the sprite sheet. Bind the same vertex position VBO to all of them, but a different texture coordinate VBO (according to what sprite / part of the texture to show). In my specific case, this would make for about 600 different texture coordinate VBOs and therefore 600 VAOs.
Create only one VAO. Set up the texture coordinate VBO in a generic way (e.g.
0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0). In the rendering loop, send the actual texture coordinates (only 4 values) as uniform variable to the shaders. In the shader, the generic texture coordinates can be used to figure out which two of the four values from the uniform should be used.
Are there other possibilities that I'm missing? What is best regarding performance?