PROCEDURAL MAP GENERATION

About

This project was created as part of my dissertation during my final year of university. Taking inspiration from games such as Minecraft, No Man’s Sky and Borderlands, this project was the result of research into how procedural generation works and how it can help create almost infinite variations of content without the need for artists/programmers to manually create every aspect.

For this project I chose to develop a map procedural generation system within Unity and was awarded a 2:1 upon completion.

Project Summary

This project was a fun but very challenging experience for me as it revolved around a lot of mathematical solutions to make sure that both the terrain would generate correctly and that the generation also had a natural look and feel to it.

The project revolved around the generation of map layouts that could be used for Battle Royale or FPS style games and creating several different environments such as a forest type map or a desert type map. The generation revolved around using Perlin Noise to generate noise maps which could then be applied to the vertices of a mesh to raise them to create the terrain. The height was also filtered via mesh data representing various biomes of a sort, with a height of 0 being sea level and 1 being mountainous regions.

In addition to the generation of the terrain the project also helped in randomly generating props that were purely decorative. For example in a forest type map props such as rocks, boulders, and trees were spawned. The user can also control the density of these props, from iterating over every vertice point and checking to see if it is a viable location for a prop to spawn to iterating every X amount of vertices, therefore decreasing the overall density

And finally when generating the map, the player is spawned on a viable point on the map and the user can also switch to birds eye view cameras to see the map from the air in all four directions.

Perlin Noise

As the foundation of my map generation lay around procedural generation I researched into various forms of procedural generation. From first researching Voronoi generation which did not suit my project and then eventually settling on Perlin Noise I created a texture system to visualize the Perlin Noise before applying it to a mesh. Starting with generating the Perlin Noise and then manipulating the values by adding values such as scale, octaves, frequency and a seed system as to not allow the same generation to occur as often.

Perlin Noise generated with a scale size of 20

Forest map generated using Perlin Noise with a scale of 20.

Perlin Noise generated with a scale size of 10

Perlin Noise generated with a scale size of 10 and a seed value of 41.

Colour Map

Before generating the mesh itself for the map I wished to see if the application of the Perlin Noise to terrain would work via a texture. After generating my Perlin Noise, I created another texture generator but this time assigning colours of the terrain onto a mesh, with each pixel colour representing a height value which it checks against Terrain Data. The terrain data itself holds the name of the biome or region and at what height it will start at.

Desert map generated using Perlin Noise with a scale of 10.

Desert map generated using Perlin Noise with a scale of 10 and a seed of 41.

Mesh Generation

With all my values generated, I used a plane mesh to generate the map myself instead of Unity’s Terrain object. The map is generated by providing the Vector3 arrays for all the vertices and how you wish Unity to connect them, as well as the UV coordinates to make sure the material applies correctly.

Once a pass through has been done on the vertices, the project runs through them again and decides whether or not to spawn a prop at a vertex position. In addition to just placing the props at a vertex position the decision also uses the Halton Sequence in order to allow the props to form a random but orderly pattern to the placement instead of sporadic randomness

What I Learned

With this being the project I developed whilst writing my dissertation I have learned a great deal around how games use procedural generation, not just in landscape or map development but in other aspects such as prop placement, weapon generation and even whole planet development

This project challenged me quite well in tackling the numeracy side of games, it has strengthened that aspect and allowed me to gain deeper insight into complex game mathematics

You can watch the demo of my procedural generation on YouTube below. Make sure to check out my repository on GitHub