top of page

Endless Procedurally Generated Terrain

The assignment

As part of my academic curriculum, I had the opportunity to pursue a specialized minor known as "Skilled," which allowed me to select my own personal learning goals. Building on my previous interests and experience, I chose to focus on the topic of procedural generation, which piqued my curiosity through a prior course, procedural art, in which a procedural neon city generator was created. The versatility and potential of procedural generation as a subject area further reinforced my decision. While I had intended to impletement biomes and biome blending techniques through wave function collapse, ultimately, time constraints prevented this.

image.png
unknown (4).png

Marching cube algorithm

The initial algorithm that I implemented was the Marching Cubes algorithm, which analyzes the values (ranging from 0 to 1) of each corner of a cube to determine whether they cross a specific threshold. This information is used to assign a unique configuration number, which subsequently guides the generation of triangles for the mesh. In order to test the capabilities of my implementation of the Marching Cubes algorithm on a larger scale, I utilized a readily available Perlin noise script, as illustrated in Figure 2. It is important to note that at this stage, the algorithm had not yet been interpolated.

Noise

The initial noise algorithm that I implemented was Perlin noise, due to its utility as a randomizer for other noise algorithms and its widespread usage in the industry. As a result, there is a lot of information available on its implementation. To help debugging and visualization of results, I began with a 2D implementation and applied it as a texture.

 

As seen in Figure 3, I implemented fractal noise, adding limitations on its values to simulate cave systems. This noise algorithm was then implemented in 3D and was included in the final product together with Perlin noise, resulting in a seamless combination of the two algorithms.

cave.png
ezgif.com-gif-maker (2).gif

Combining Noise

To generate the terrain and cave systems, I used two distinct noise algorithms. The first one, a 2D Perlin noise, was utilized for the generation of the top layer which can handle multiple octaves of Perlin noise. This is the ground layer, therefore it should be noted that the generated terrain is not a uniform flat surface.

For the cave generation, I used a 3D fractal noise function, which also has the capability of handling multiple octaves. In order to effectively combine these two noise algorithms, I developed two formulas. The first formula ensures that the cave systems become increasingly scarce as one approaches the ground layer, while the second formula ensures that the lower one goes from the ground layer, the more air pockets there are.

By merging these two formulas, I was able to achieve a relatively realistic terrain, with natural openings and caves becoming more prevalent at lower you go.

Objects

As the minor came to an end, I used the remaining time to implement object placement, specifically the placement of trees. The trees were spawned in clusters based on the previously generated Perlin noise. To add realism and diversity, three different types of trees were used, with their placement determined by the elevation of the terrain. Specifically, spruce trees were the only type of tree that spawned at higher elevations, and no trees were placed above a certain altitude.

Videos

Extra

Interesting algorithm i created along the way

bottom of page