by L. Spiro » Mon Nov 12, 2012 11:43 pm
I may have misunderstood the question, but I am not sure what you see as the main hurdle to sharing data between vertex buffers.
Sharing vertex buffers between meshes of a single model is quite common, since artists often just copy-paste one part the other side. The wheels of a car are often just the same vertex buffer with a reversed transform applied (and thus reversed culling).
In this case the whole vertex buffer is shared between the subsets (meshes) of a model, but I don’t think this is what you meant by your question.
Then there is the case of instances of models, in which each instance just references the base model’s vertex buffers. Again I don’t think this is what you meant.
I think you are talking about 2 meshes that use the same vertex coordinates and normals, but different texture coordinates (for example).
But the answer is actually the same.
The vertices and normals are in one shared VBO. Each model has its texture coordinates in a different VBO.
Streams (the term used by DirectX) are used to swap between the combinations of vertex/normal VBO’s and texture-coordinate VBO’s.
In other words, just activate VBO 1 and VBO 2 together, then activate VBO 1 and VBO 3 together.
No extra layers needed.
If you want to encapsulate this behind a VBA, you need one VBA for each possible combination (in this case 2). This doesn’t change what is ultimately happening though, and if you do use VBA’s I suggest not adding them as a hidden feature of the VertexBuffer class, but as their own new class. Otherwise you don’t have a very intuitive way of flexibly making all the combinations of VBO’s you will need.
L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them.
- L. Spiro 2011