Hi,
Is it possible to use vertex arrays / indexed lists (e.g. glDrawElements or some version of it) when I have a triangle mesh with a different number of normals and vertices?
Take a simple example: a cube has 6 faces (12 triangles) and 8 vertices. But we actually have 6 unique normal directions (one in each direction of the faces of the cube).
So if vertices and normals are each represented as 3 floats, then the vertex array would have 83 = 24 floats, and the normal array would have 63 = 18 floats. For proper rendering, each vertex needs to be drawn three times (each time with a different normal) because each vertex is shared by three faces, each with its own normal.
Is there a way to set up indexed lists / vertex arrays to do this? It could be done by replicating the vertex data, but this seems like a waste.
You can’t have separate index arrays for vertices and normals, so you have to duplicate vertices/normals. A cube, for example, requires 24 vertices and normals.
It turns out that for decent-sized meshes (a cube is not decent-sized) the overhead of sending extra indices for texture coordinates, normals, and vertice separately, bloats the model data so it’s bigger than just generating normalized unified vertices and a single index list.