This terrain generation tool is created to generate simple terrains starting from heightmaps. These heightmaps can be provided by the user or they can be generated by the tool. As the terrain can become rather large, it is possible to divide the terrain into chunks to reduce the amount of resources required for generation and loading. The tool also includes the ability to change the terrain over the seasons by varying the amount of grass and snow when the seasons change.

Features:

  • Terrain generation based on height maps.
  • Height map generation.
  • Terrain division into chunks.
  • Seasonal changes to the terrain.

Generation

To create a new terrain asset, a terrain script is attached to the object that the player wants to generate terrain for. Then a heightmap has to be given to the script. The user can choose to create a heightmap themselves, or they can use the built-in Perlin noise generator to generate a heightmap for them. Then the heightmap is divided into smaller chunks which all have a set size decided by the user.
Then the terrain itself is generated, this is done by creating planes with the same amount of vertices as the size of a chunk. The diagonals of this plane are randomly rotated to make the terrain seem more randomized. Then each vertex of the terrain is multiplied by the white value of the corresponding pixel, where white is the highest height and black is the lowest height.

Chunks

This process is executed for each chunk individually until the whole heightmap is converted to a 3D mesh. When the script is executed in the editor, the terrain is completely generated immediately and when the script is executed in play mode, a coroutine is used to generate the terrain, this way, the amount of time per frame that the terrain is generated can be limited to prevent lag.

Seasons

The terrain tool also allows for changes depending on the season. In the editor, the snow and grass heights can be changed depending on the season, for example, the snow is limited to 50 units height in summer, but can move down to 30 units of height in winter, making the map more covered in snow during winter. The terrain is colored using a shader that draws different colors depending on the polygon height and polygon angle.