Have you ever played a game like Minecraft where a completely new, unique world is generated every time you load in? How does that happen? What is the process that creates this entire world and how do we make sure it looks real-ish?
You can't generate something from nothing. Minecraft's diverse landscapes are generated from what is known as a "seed". Essentially, a seed functions as a set of data the code in a game can use to generate the world. The code interpreting the data then acts as the "rules" which guide the terrain generation.
In order to generate terrain, we need a foundation - some data to we can manipulate and analyze with our code. This is where "noise generation" comes in!
Perlin Noise is a process by which a 2D region is shaded with a grayscale coloring. The trick, however, is to make sure that the transitions between colors don't happen too quickly. This yields sections of dark black and regions of bright white weaved together with a little gray in-between. The code for this was implemented using Unity's freely available game engine.
Once the noise had been generated, we wrote code which mapped the "darkness" of the color in the Perlin noise to different heights. In the code, lighter areas became taller and darker regions remained lower.
This code could be used to turn a 2D noise map into a 3D mesh with depth!
With the 3D mesh created, the student decided to define regions based on height. By assigning different ranges of heights to different colors, the student created a map with a touch of realism! Higher regions were assigned to a brownish, mountain material and lower regions were assigned to a blue, water material. Now, with the click of a button, the student could generate entire regions in less than a second.
Phase II of this project involves using the regions generated as environments for gameplay. You can see a few more of the random regions generated below!