DEV Community

Alec V
Alec V

Posted on

Procedural Generation

Procedural generation is a method of creating data algorithmically through a combination of rules iterated through with a degree of randomness. It is used in computer graphics to create textures and models. It is used in movie computer-generated imagery to produce large landscapes and simulated crowds. Music can be generated algorithmically, either to avoid repetition or to allow it to change in real-time based on predefined stimuli. Procedural generation can create large amounts of content that adheres to specific rules.

Procedurally generated trees using L-systems

Procedural generation made its way from dice roll generated dungeons in Dungeons and Dragons into early video games like Maze Craze(1978), Apple Manor (1978), and Rogue (1980). Rogue used procedural generation to create unique dungeons so that every playthrough was different. Rogue gave rise to a host of similar games known as rogue-likes, which is a popular buzzword in today’s computer game industry. Procedural generation allowed these early games to create large amounts of content while using only a small amount of memory.

A Procedurally Generated Dungeon in Rogue

In modern games procedural generation is used to create content like terrain using techniques like Perlin noise, Simplex noise, fractal noise, and cellular automata, or creating variations from an example using deep neural networks trained on real terrain data. These processes generate unique maps for games and build worlds with unpredictable weather patterns, ecosystems, climate, and geological processes. Physics-based procedural generation creates landscapes by simulating the process of erosion. The three-dimensional worlds are colored by textures which can also be procedurally generated so that no two objects look exactly the same. Developers of these systems must balance the processing power required to produce these landscapes with realism.

A procedural landscape rendered in Terragen

Perlin and Simplex are gradient noises that were developed by Ken Perlin in 1983 and 2001, respectively. They are used to generate terrain and textures procedurally in 1 or more dimensions that are more aesthetically pleasing but more computationally demanding than value noise, which generates random values between grid points and then a smooth gradient between them. Simplex noise is an improvement on Perlin noise. Simplex noise is more computationally efficient than Perlin noise and can scale to more dimensions efficiently. Simplex noise generates more aesthetically pleasing results with fewer artifacts. Perlin and simplex noise can be layered into fractal noise to increase realism and control the variations.

Perlin noise, rescaled and added to itself

Cellular automata consist of discrete objects whose state evolves over time, usually following rules based on the state of surrounding objects. An early example of this on a computer is found in Conway’s Game of Life. Cellular automata are useful for terrain generation, real geologic processes can be simulated to create realistic landscapes. They can be used to simulate anything that changes over time and can produce unexpectedly complex results.

Conway's Game of Life

Image source: https://www.jakubkonka.com/2015/03/15/game-of-life.html

Deep neural networks are increasingly used in procedural generation. They can create more complex results and enhance the quality of procedurally generated content. Convolutional neural networks are a class of deep neural networks trained on images that are particularly suited to image generation. They can be trained on large datasets like real-world terrain to generate more realistic terrain.

Procedural generation is an incredibly powerful tool for content creation. Manual creation is time-intensive and necessarily limited by memory or labor constraints. Procedural generation allows creators to specify a set of rules by which something will be created and then create near-infinite variations. Deep neural networks have enhanced procedural generation and with increasing processing power and more complex systems, procedural generation will only improve.

Lim, F., Tan, Y. and Bhojan, A. (2022) ‘Visually improved erosion algorithm for the procedural generation of tile-based terrain’, Proceedings of the 17th International Joint Conference on Computer Vision, Imaging and Computer Graphics Theory and Applications [Preprint]. doi:10.5220/0010799700003124.
Fischer, R. et al. (2020) ‘Autobiomes: Procedural Generation of multi-biome landscapes’, The Visual Computer, 36(10–12), pp. 2263–2272. doi:10.1007/s00371-020-01920-7.
Zhang, J. et al. (2019) ‘Example-based rapid generation of vegetation on terrain via CNN-based distribution learning’, The Visual Computer, 35(6–8), pp. 1181–1191. doi:10.1007/s00371-019-01667-w.

Top comments (0)