I'm a fresher on engine programming. I have a question of how we can get the vertices buffers of vertex formats from the mesh file.
For example, in OBJ file or FBX file, we save the positions, normals separately. So the whole mesh file is a structure of different arrays which contain the different attribute of the vertices.
But when we offer those data to the graphics card, we'll offer an array of vertex structs, here the vertex struct contains the position, normal, UV... for one vertex.
So, suppose we want to generate different vertex buffers for different shaders from the mesh file(the struct of arrays), then I think we can use 2 solutions:
generate a different array of structs, here the different struct will be the different formats of vertices. The problem is: It takes a lot of memory to save the different vertex buffers.
generate a general array of struct, here the struct contains all of the vertex attributes we can get from the mesh file, and use offset to get the correct data for different vertex format. The problem is: will it be slow for shader program to access the vertex data?
Which one is the better way to do? Or is there any better solution? Again, I'm just a fresher, So I hope my description is clear enough for the problem :-)
Thank you all very much!