top of page

Utilising Procedural Generation Techniques to Construct Organic 2-Dimensional Levels

Procedural Content Generation (PCG) is one of the most important aspects of modern games. It can be utilised to map large areas of space within a very short time-frame with little resource expenditure. For some games, PCG is used to such an extent that it is the primary mechanic and selling point.

 

Using Unity, I wish to develop a large-scale, 2D top-down survival game that is entirely procedurally generated. It is my aim to use a few PCG development techniques to produce the world of the game. This means during runtime, the terrain, foliage, and resources will be generated in an organic and realistic way.

 

For the terrain I am going to use Perlin Noise for the Overworld, and Cellular Automata for the Caves. These AI techniques will automate the tile maps of the level. The game objects such as trees and raw materials will then be placed using “Poisson Disc Sampling '' to give them an organic layout in the level.

Trees, rocks, animals and other natural resources will be dotted around the map for the player to harvest. Some items will be rarer than others, or will only spawn in specific biomes. With the goal of the game being to sail home on a hand-crafted boat, the player will be pushed to explore every inch of the play space to gather the resources required to escape.

Main Menu Design

Terrain Development Process

Perlin.png

The first step in generating a procedural overworld is to produce what is known as Perlin Noise, a procedural texturing primitive that outputs a pseudo-random gradient vector. The outputted image is greyscale, but can be further manipulated. Most people recognise Perlin Noise due to its use in Unreal Engine's material blueprints, where it is used to overlay effects such as rust to add additional realism and dimension to a material.
 

Perlin Colour Map.png

The pixels' values are between 0 and 1. By shading these points depending on the magnitude of the vectors, the map can be viewed as terrain. This example has the lowest bounds coloured blue to represent deep water, with lighter blue reflecting shallow waters. Beaches are followed (yellow) and then two grassland biomes finish the illusion at the higher values of the pixels. This is still just an image however, so the theory behind this is taken to a tilemap.

Perlin Tile map 1.png

By painting a tilemap grid with tiles instead of pixels on a render texture, a playable scene is created. changes to the number of octaves, the lacunarity, persistence and noise scale results in a much better map in terms of play-space. the previous generations had a lot of terrain within too little an area.

The premise of my game is that you are stuck on an island, so we must apply a square gradient to lower the outer edges of the level to 0 (water). Doing this will also nicely produce beaches around the circumference of the island.

cave generation.png

On the cave generation side of the project, I have almost managed to produce a series of interconnected tunnels and caverns. Cellular Automata is a process in which coloured cells (in this case, the tilemap) "evolves" over a series of iterations. These changes are defined by a set of rules set by me that judges whether a cell should become wall or become empty space.

A few tweaks to the way the tiles connect to one another and the next step will be to populate these caves with resources and monsters, as well as find a way to spawn in an exit to the overworld.

bottom of page