I have a level I need to render. It is broken into hundreds of submeshes with information on which submesh can see which submesh. Each level has a pool of textures that all of those submeshes can reference. All submeshes have vertices that are sorted by texture. Here is an example.
Submesh 1
Index[1, 3, 4, 5, 6, 2, 7, 8, 10...] Texture 1
Index[12, 15, 16, 12, 13, 19] Texture 2
When there are 1000 submeshes and 20 textures possible, the amount of texture swapping gets ridiculous even factoring in visibility.
I have all of my submeshes sequentially in a VBO. I have been trying to figure out the best way to go about optimizing rendering and eliminate all unnecissary texture swaps. If I just sort the VBO, I lose the submesh connections and the visibility data becomes useless. Or is there a better way to do that?
Or should i create an index list every frame based on visibility or is that too slow?
Edit: Here is a breakdown of my current setup.
VBO with all of the vertices in order running from submesh 1 texture 1, submesh 1 texture 2, all the way to submesh n, texture n.
I have an IBO which is just all of the indices to all of the meshes, in the same relative order.
When I render, I consult the submesh and have an starting index and count which are the start index in the IBO for that submesh and texture and then the count which is the number that have that texture.
This is essentially why I am doing so much swapping which is really slowing things down.