At what size should a mesh be split into several meshes

I am currently working on a custom generated hex tile map. The mesh is currently at approx 25000 vertices for a grid size of 5 x 5 hex tiles. As I increase the size of the map, at what point should I split the mesh into separate chunks to increase performance?

Hex grid

It depends if you want to modify it and how long it takes to generate in the first place - and how much it matters if it does take 300ms to load…

It is not going to be dynamic, I generate it only once. Time to load is not a concern, right now I can generate a 100 x 100 map in ~2 seconds. For the 100 x 100 map the mesh has ~10 000 000 vertices. Are there any benefits to splitting it up, like lightmap size or culling?

Yes… culling.

If you don’t split it then the GPU will always be processing 10,000,000 vertexes even if you are looking at the tiny corner.

As to the first question, it still depends. Your scene, how often the whole thing is in view, how often parts are in view, etc… all matter. Experimentation is kind of the only real way in the end.

2 Likes

I modified my code to generate the map using a chunk-size of 3 x 3 hex cells. This gave a massive speedboost, thanks for the input.

Note that it’s a tradeoff… lots of objects in your scene will also slow things down. Finding the balance can require some experimentation.

Is there a rule of thumb to how many objects are too many?

It depends on a lots of things… mostly how well organized the scene is, how many are on screen at once, etc…

For every object or every hierarchy of objects, culling must be performed. We’ve made changes so that at least the update loop doesn’t spin through all of them unless they actually have controls but number of total objects and number of geometry objects on screen are still a concern.

Make the split configurable. Experiment with it over time. You may find that once you start adding other things to your scene that you’ll want to have fewer splits in your terrain (to reduce the object count) at the cost of a few wasted vertex transforms on the GPU (which is really good at that).

Edit: by “configurable” in this case, I mean a constant somewhere that you can easily change.

Sounds good, my code does exactly that:

public static int chunkSizeX = 3;
public static int chunkSizeZ = 3;

And I create a grid like this:

HexGrid hg = new HexGrid(xChunks, zChunks);

Thanks for all help so far!