Vertex data split into separate buffers or one one structure?
- by kiba2
Is it better to have all vertex data in one structure like this:
class MyVertex
{
int x,y,z;
int u,v;
int normalx, normaly, normalz;
}
Or to have each component (location, normal, texture coordinates) in separate arrays/buffers? To me it always seemed logical to keep the data grouped together in one structure because they'd always be the same for each instance of a shared vertex and that seems to be true for things like character models (ex: the normal should be an average of adjacent normals for smooth lighting).
One instance where this doesn't seem to work is other kinds of meshes like say a cube where the texture coordinates for each may be the same but that causes them to be different where the vertices are shared.
Does everybody normally keep them separate? Won't this make them less space efficient if there needs to be an instance of texture coordinates and normals for each triangle vertex (They won't be indexed)?
Can OpenGL even handle this mixing of indexed (for location) vs non-indexed buffers in the same VBO?