Large amount of procedural meshes performance issue

I’m new to UE, I may have missed a simple fix for this.

I’m generating a procedural hex world, and I’m getting some pretty good results so far.

These hexes are made with procedural meshes because the hexes are all of slightly different sizes to make the map more interesting to look at.


This map is ~40x25 hexes, ~1000 hexes, ~6000 triangles

But when I scale things up to make bigger worlds, the game slows to a crawl.


This one is ~190x110, ~21k hexes, ~125k triangles

I have all the coordinates for the center and each corner of the hexes.

How I thought of fixing this performance issue:

  1. I thought of doing a LOD to despawn the hexes further away to save ressources, but I can’t find how to do this for a procedural mesh, is it even possible?

  2. Another option would be to take a single, large, flat rectangle mesh, and “paint” the hexes on it, but I honestly have no clue how to do such a thing.

  3. Yet another option, which I do not know if it’s possible, would be to convert the procedural meshes into a static mesh after generation, I do not require the map to be altered during gameplay.

  4. Resign to have a smaller map :frowning:

If anyone has a pointer on how to fix this it would be much appreciated!

Instanced static meshes, I would say.

Look into the “sections” in procedural mesh. You can decide to update just a specific section rather than the whole mesh which could be faster? If you’re using UE5 I’d recommend switch to UDynamicMesh instead.

Have you considered putting the hex instances into a hierarchical static mesh?

If you’re making a procedurally generated world, the #1 issue/problem is optimizing the world gen/modification so you won’t find an easy option. Your best bet is a combination of all of these but at a minimum:

  1. Def make it into a static mesh if you don’t need to modify it. This requires some in-depth c++.
  2. Create a chunk system so you don’t need to have the entire world in your scene at one time (like minecraft)
  3. I wouldn’t “paint” the hex pattern on because you will probably want to alter the height of the map. If you don’t plan to alter the height and just want a flat world, however, then definitely just make a single quad and convert your hex mesh implementation into a texture shader.
  4. LOD will be good for performance but requires a lot of work with less perf boost than previous, look to this after you’ve implemented all the other optimizations you can think of. Also, what you said about not finding a way to despawn the further hexes, you would have to implement that yourself.

I’ve been googling the various answer, and I’ll be honest I know nothing about any of them, so I have a few questions.

Instanced static meshes and hierarchical static meshes, can they be of different shapes and sizes? Each hex in my grid has a unique shape, hence the procedural meshes.

For the procedural mesh “sections”, I see there’s a “section index” input, but I’m not sure how I would set it up to do what you’re telling me? I tried adding a “Set max draw distance” node, but the whole map is one giant chunk that pops in/out at once.

I’m thinking that I would be splitting the “ProcHexagon” into multiple ones scattered around the map, “chunks”?

As for the UDynamicMesh, I believe that’s C++? I’m likely going to have to dig into it at some point I guess, is it a reasonable undertaking for someone new to C++?

Same for converting from procedural to static mesh, how complicated is it for a new coder?

Sorry for the flood of questions, there’s so much to learn in UE it’s crazy.

Oh and yes, I’m using UE5.

I’ve been googling the various answer, and I’ll be honest I know nothing about any of them, so I have a few questions.

There should be a dynamic mesh component. FDynamicMesh3 was added to middleman all other mesh types in unreal. IE you can convert a DynamicMesh to a static mesh or a procedural mesh which makes it more flexible than any other mesh type that comes with the engine.

I haven’t used sections myself, but what I’m thinking in my head is that each of you hexagons is it’s own unique section of the mesh, and so when you go to make an edit to the tile, only that tile gets rebuilt. That should at least be a bit more performant.

It will require you to keep an index that ID’s each mesh section so you know which hex to edit, but that’s not too difficult.

Same for converting from procedural to static mesh, how complicated is it for a new coder?
. .