Following Red Blob Game’s rundown of creating terrain maps from noise (for the most part) I’ve managed to use the material editor and render targets in UE4 to make a customisable terrain generation tool that could be used for a variety of maps (not necessarily Hexagonal ones).
The Noise Material
Taking in the local position with a user defined offset parameter, I combine 3 different frequencies of Simplex Noise. These frequencies are then multiplied together and then clamped to between 0-5 (as I have 5 steps of terrain height for my tiles)
The user can also decided to restrict the terrain to be contained as an island. Admittedly this is somewhere where my mathematical knowledge let me down, as I don’t currently understand quite how to reshape the terrain towards the centre as described in the Red Blob Games page. My solution to that was to simply mask out the terrain with a circular gradient mask with a variable width and density.
The Map Generation Manager
The manager itself is quite simple; it creates an instance of the noise material with the user’s settings, and renders it to a render target. This render target can then be accessed by all the tiles individually. Although the tiles themselves each get their own height, it’s actually the manager that holds the maths for obtaining the heights from the render target.
The Noise is projected to a render target
Map gen gets the furthest tiles in X and Y
Each tile asks for it’s new height
The map gen reads the pixel at the correct location based on the range from low and high X/Y
Tile sets it’s new height from the value of the pixel at the correct location.
I’ll still need to Fine tune the limits to always be within something playable, but the base is there. I might improve the system further to include:
More user control as to how the heights are banded
Terrain features and resources being generated