Download

Question regarding performance and texturing of generated hex-field-terrain

Hello there,

I am currently working on a HexGrid based Terrain system, for a civlization type game. Instead of using a separate mesh for each hex, I tried to precdurally generate each hex separatly and combine it into one single mesh, using my own Component in C++. For starters, I have generated a simple square grid, where each square is extruded separatly, to sort of simulate what happens when I generate the terrain for my game. I am currently testing stuff with a 512x512 grid, and even though it takes a few seconds to intially build the mesh, it runs sort of smooth. However, I allready am getting some performance concerns and wonder what I could do to improve performance.

I thought about splitting the mesh up into separate smaller meshes, which each reside in their own component. I wonder if this will improve performance, when only a small porting of the overall grid is displayed. I am very new to this topic, so any tip regarding perfomance optimization of any sort would be highly appreciated.

Also I wonder how I would approach texturing the grid. Currently I am using a plain white Material, however, for my game I need to texture each hex individually. I thought that layered materials might be the way to go, but for this i sort of need to generate a map, that tells my material which texture to put where on the mesh. How can I generate such a texture map out of my existing grid data, so I can use it to feed a texture parameter on a metrial instance to texture my mesh?

Any hints would be highly appreciated.

Thank you very much

You made one single mesh that is either displayed or not, not much optimization can be done here.
Engine already has instanced mesh actor for such tasks, and its optimized.
Now it all depends on your tiles of hex grid, if they really procedurally generated (ie. no 2 tiles are same) or you use tiles like civ games have (ie. same hill tile just rotated and painted).

In first case you cannot optimize it much more, besides lower polycount, some world aligned material (not sure if this gives you any optimization), probably splitting that map into meshes can give you bit more speed on rendering but will waste as much if not more on loading data to gpu.

If your game will use true tillable tiles, then there is map generator thread, you probably get all possible tips there about instanced meshes and creating civ map. It is done with blueprints but you can transfer all ideas over to C++.

Use search, you will find a LOT of useful threads.
Hex fields is a relly popular theme on this forum!
My old thread
Zeustiak Map Generator Thread 1
Zeustiak Map Generator Thread 2
Zeustiak Map Generator Thread 3