Hi!
It is actually either a single VB with A+B+C+D+E+F
Yes. For v2 meshes, it is a single VB with A+B+C+D+E+F.
For v1 meshes, any arbitrary combination is possible (e.g. 3 VB with A; B+C+D; E+F).
This limitation is imposed by OgreNext and not by the RenderSystems, which comes from our ability to do multi-mesh instancing via some baseVertex and baseInstance tricks (basically boils down to APIs allowing us to specify a different buffer offsets; and that's how multi-mesh instancing works).
If we were only to target Vulkan & D3D12 perhaps we could make this restriction go away, but even then it is deeply in-grained into OgreNext right now.
This is a controversial choice because there are a few reasons to use multi-buffer meshes(*).
There was some WIP createMultiSourceVertexBufferPoolImpl which was in theory designed to allow multi-vertex buffer v2 VAOs. But it was never completed. It was too difficult to get it to work with baseVertex/baseInstance and there was no interest for it.
(*) One of those reasons is shadow map rendering (e.g. putting the poisition data in its own buffer) but we workaround that by cloning the vertex & index buffer, stripping it of irrelevant data (like UVs and normals) and then merging all redundant vertices. That's why you'll see we have 2 Vaos per Mesh (VpNormal and VpShadow) and they can either be the same VAO (i.e. no clone and stripping) or different VAOs (cloned and stripped).
VertexShadowMapHelper can automatically perform this operation for you.
I need to add custom vertex element (like TEXCOORD4) to an existing mesh loaded from mesh file. It has all vertex elements packed within a single VB and I can create new VB with added element, copy the old vertex buffer with adding new values to the vertices or I can just create new vertex buffer and simply add it to the VAO (so there will be original VB with position+normal+uv0) and my newly added vb which stores uv4.
A couple things:
1. We have functionality that helps dealing with this. See VertexBufferDownloadHelper.
You basically tell it what semantics you want them to download and returns you all the pointers to the data so that you can modify it.
Since you want to add a TEXCOORD (and you can't simply add a vertex buffer) you can use VertexBufferDownloadHelper to copy all data into a new, larger buffer and then add your extra data.
2. v2 VAOs vertex buffer order have no requirements and the order in which you specify the semantics are the order in which the elements must appear in the buffer.
The only gotcha is that:
-
Internally OgreNext may assign some arbitrary number to them. For example in GL3+ vertex attributes map to a predefined number. See GL3PlusVaoManager::VERTEX_ATTRIBUTE_INDEX. However I don't see how you should have to worry or even know about this. It's an implementation detail.
-
In GL3+ we map VES_BINORMAL to vertex index 16. This may not work on some GPU/drivers that advertise 16 slots (i.e. slots 0 through 15). Just use something else, like VES_TEXTURE_COORDINATES. The details are explained in this comment.
Are there any restrictions due to render systems? Is it still necessary to order the vertex elements in certain order like it was in DX9? Or in D3D11 and GL3+ it doesn't matter anymore?
As far as the API goes, it doesn't matter anymore. What's way more important nowadays is that the vertex isn't fat. e.g. use half16 or unorm8x4/unorm16x2 when possible instead of float32. Try to make it as small as possible per vertex.