Vertex data split into separate buffers or one one structure?

Posted by kiba2 on Game Development See other posts from Game Development or by kiba2
Published on 2012-12-17T22:11:05Z Indexed on 2012/12/17 23:14 UTC
Read the original article Hit count: 214

Filed under:
|
|

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?

© Game Development or respective owner

Related posts about opengl

Related posts about 3d