Procedural generation of terrain generally refers to generating terrain based on certain algorithms. It has been used extensively throughout the years to randomly create everything from the enemies that spawn, all the way to the worlds that you explore.
Procedural terrain generation involves lot of mathematics in it. So, if you don’t like mathematics or don’t understand it then the best way to generate a terrain is using a 3rd party application. If you are using unity then you can use the assets available in unity store for this purpose. Here are the best unity terrain tools.
There’s a bunch of ways that programmers use to create procedural terrain. In this article, we are going to outline two of them.
Pattern procedural terrain generation
Procedural map generation that relies on pure randomness can lead to catastrophic results. The algorithm might produce maps that are insurmountable to the player, either because the geometry is impossible to navigate or the maps are populated with incredibly tough enemies that the player, at that point in the game, cannot deal with.
Ways developers can deal with the problem is by creating the rooms that will be used in the game themselves and just have the algorithm stitch them together to create a level. Think of it like assembling puzzle pieces. This is also be done using fractals
A fractal is defined as a geometric shape that infinitely repeats itself when zoomed in or out from. Therefore, they are perfect for creating terrain. In order to introduce even more randomness, developers also use a few Noise algorithms to generate map layouts
The castles in Rogue Legacy and the spaceships in Heat Signature both include hand-crafted rooms that the game puts together while adhering to some basic rules that dictate difficulty. For example, in Rogue Legacy, the rooms closer to the entrance are simple but the further you delve into the castle, the game will use darker and more geometrically challenging rooms populated with tougher enemies.
In Heat Signature, if the player chooses an easy mission, then the game will automatically design a ship that the player can invade with little resistance, as the enemies will be easier and the rooms chosen will probably not have many environmental hazards.
Terrain generation in games like Minecraft and No Man’s Sky, on the other hand, is incredibly complex and requires knowledge in some pretty advanced mathematical concepts.
Random generation usually includes generation of height map and generating terrain from the height map. For those who don’t know what a height map is? , it’s a 2d image that stores the elevation details in every pixel used to render 3d maps in games. This method of random terrain generation is not pure random and is controllable to a large extent.
One of the most used algorithms is Random displacement algorithm. In this a random number is assigned as height value to each corner of the rectangle (initial plane). Then the plane is subdivided and value is assigned randomly again. This is done until the required complexity is achieved.
More random terrain can be formed using noise generation. Noise generation is normally used only for textures and effects, but if a complex terrain is required then noise can be used to generate the height map. Most commonly used noise generation algorithm is Perlin noise algorithm.
Making a random terrain only with code is an expert level job in game development. So, if you are not an expert programmer, it’s better to go with 3rd party application of terrain generation. It saves you tons of time which you can used to make your game better.
You can learn more at these courses in udemy.