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

Hey Brainshack -

Without knowing the exact look you are going for there are some generic suggestions I can give you. The Engine renders items in batches based on shared shaders (materials). So you would definitely want to make use of a Master Material setup with Instances of the Material used for variation. Also keep in mind you will want to setup a LOD (Level of Detail) system which is probably the one performance boosting mechanism that many people do not do. This will mean looking at reducing vertex counts in the distance but also looking at ways to remove unnecessary detail from materials at a distance. We have many materials in Starter Content with this Camera Distance LOD setup in place.

Ultimately I think it be beneficial to give yourself a series of hex units already completely textures which are also tileable with each other and have your hex grid calculations pull instances of those units and apply them to your world. Assuming that you are using instances and a master material setup you should get reasonable performance.

Hopefully this gives you a start -

Eric Ketchum

Hi Ash,

thanks for the tipps. I started looking into instanced mesh, and the results so far seem promising. I wonder if there is a way to assign a material per instance, or do I have to have an instanced mesh instance for each mesh with each individual material?

Hey -

You would need to do a new grouping of instances for each new material. I would even go so far as to do a series of parented blueprints with each instance its own blueprint actor that is then spawned from a parent blueprint.

Pika Pika

Eric Ketchum