Original Post
Hi, I have a conceptual problem about texture sorting. For the moment, my meshes can have a lot of subsets, each ones with different texture sets. BUT they are stored in a single vertex / index buffer. So each frame, I have a code looking like this one : (To keep it simple, I assume all the materials use only one texture channel ^^) Well, now imagine I want to implement a renderer. Now, my meshes would pass their buffers, textures, etc. to a renderer. This allow me to sort all the data by texture (for example) But i'm stuck : a single vertex / index buffer uses many different textures ! So, thought about 2 solutions : 1) 1 vertex / index buffer == 1 texture set. So I don't have any more problems. The drawback is : I have a lot more SetStreamSource, SetIndices to do. And I now have a lot more small batches, which is not really good. 2) I sort by texture, but I don't consider drawing of an entire vertex / index buffer, only a subset. But this way, I'll have many redundant SetStreamSource and SetIndices. So, anyone has an idea on the performance issues of these solution ? Or can suggest me another one ? Well, thx in advance for any help / pointer ^^
// set the FVF and the vertex / index buffers
m_pd3dDevice->SetFVF(m_FVF);
m_pd3dDevice->SetStreamSource(0, m_pVertexBuffer, 0, m_VertexStride);
m_pd3dDevice->SetIndices(m_pIndexBuffer);
for (int i = 0; i < m_NumSubsets; i++)
{
m_pd3dDevice->SetMaterial(&m_pMaterials);
m_pd3dDevice->SetTexture(0, m_Textures[0]);
m_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, m_BaseVertexIndices, m_MinIndices, m_NumVertices, m_StartIndices, m_PrimCounts);
}