Procedural terrains
Platform
Windows
Language
C++/HLSL
Project Type
Course Work
Role
Solo
Duration
~3 Months
As part of a 3rd-year module, we were tasked to create an application which generated some sort of procedural content. One half of my application was a terrain generator, the other half is discussed here. ​
​
​
​
​
​
​
​
The foundation of this program is Perlin Noise, originally created in 1983 by Ken Perlin (the code for this). This process creates images which appear to be random, but are in fact easily reproducible, this works by giving the algorithm a set of starting coordinates and so it will output the same image. Several different procedures can be done on this base height map, shown below.


This texture can also be scaled by how far each point is from the centre of the map (i.e the further away it is the less impact it has on the final map) to produce an island effect. The final image is then loaded into the Graphics Programming framework (more on that here) and used as a height map.
To add an extra depth to the generated terrain, some semi-realistic rivers are generated.
This works on the simple principle that rivers will take the path of least resistance as they travel downhill. To start a random start location is picked and then the river will travel through the height map going downhill, once it's found the lowest point it will return to the starting location and travel upwards through the map until it reaches the highest point it can reach. To make this process easier for me to code I modified my pathfinding code from the year before, discussed here. To make the river look more realistic, i.e to simulate the banks of the river, the image that the 'pathfinding' created was then blurred (using the pseudo-gaussian blur technique used here) and then applied to the terrain, this is shown below.

However, the rivers were still a tad too straight for my liking at this point. As such a further step was carried out to fix this problem. Firstly, a new Perlin map was generated and then subtracted from the blurred river map, the resultant image was then blurred again. The rivers that were now generated had a significantly more variation at their edges.


The next process was to colour the various parts of the terrain, for the land this was a blend of green and grey, depending on the height (the difference between the highest point and the water level) and slope (i.e. higher and steeper sections were more grey). For the water, this used the depth (the difference between the lowest point and the water level) to colour it increasingly darker shades of blue. The border between the water and land was coloured in a yellow to represent beaches and river banks, in the case of the banks the higher they were the less yellow was used. All these can be seen below.

To make the beaches more realistic two extra processes were carried out. The first being to make the upper limit of the beach negatively correlated with the height of the overall terrain, this being the flatter the terrain was the higher up the beaches were.

The second was to add some variance to the upper limit of the beaches, this was done by using a third Perlin map increase the level so the beaches would naturally differ in height across the terrain.















