LayerProcGen v0.4.0
Layer-based infinite procedural generation
Loading...
Searching...
No Matches
LayerProcGen

LayerProcGen is a framework that can be used to implement layer-based procedural generation that's infinite, deterministic and contextual. It works out of the box in Unity but can be used in any C#-compatible engine.

Documentation - GitHub - EPC 2024 Talk - Discussions

The framework does not itself include any procedural generation algorithms. At its core, it's a way to keep track of dependencies between generation processes in a powerful spatial way.

Generating infinite worlds in chunks is a well-known concept since Minecraft.

However, there is a widespread misconception that the chunk-based approach can’t be used deterministically with algorithms where the surroundings of a chunk would need to affect the chunk itself.

LayerProcGen is designed to help with just that.

Features

Contextual & deterministic
A central purpose of the framework is to support contextual generation while staying deterministic. Procedural operations can be performed across chunk boundaries, producing seamless results for context-based operations such as blurring, point relaxation, or path-finding. This is possible by dividing the generation into multiple layers and keeping a strict separation between the input and output of each layer.
Contextual Generation

Plan at scale with intent
Chunks in one layer can be orders of magnitude larger than chunks in another layer, and you can design them to operate at different levels of abstraction. You can use top-down planning to e.g. have road signs point to distant locations, unlock entire regions based on player progress, or have NPCs talk about things at the other side of the continent.
Planning at Scale

Bring your own algorithms
You implement data layers by creating pairs of layer and chunk classes, and you can use whichever generation techniques you want there, as long as they are suitable for generation in chunks on the fly.
Layers and Chunks

Handles dependencies
The framework makes it possible to build many different chunk-based procedural data layers with dependencies between each other. It automatically generates depended on chunks when they are needed by chunks in other layers, or by top level requirements.
Layer Dependencies

Two-dimensional infinity
The framework arranges chunks in either a horizontal or vertical plane. It can be used for 2D or 3D worlds, but 3D worlds can only extend infinitely in two dimensions, similar to Minecraft. The infinity is pseudo-infinite, as it is limited by the range of 32-bit integer numbers and the specifics of which calculations you use in your procedural processes.

Multi-threaded
The framework is multi-threaded based on Parallel.ForEach functionality in .Net. The degree of parallelism automatically scales to the number of available cores. When needed, actions can be enqueued to be performed on the main thread.

Fixed-point coordinates and floating origin
The framework is designed to support large worlds without suffering from floating point precision issues. Calculate your generation in fixed point world space coordinates, subtract the floating origin, and convert the results to the floating point scene space coordinates used by the game engine.

Made with LayerProcGen

Released games:

Games in development:

Getting started

For use in Unity, LayerProcGen requires Unity 2019.4 or later:
Getting Started in Unity

For use in other engines, see:
Using Without Unity

Platform support

The functionality should in general work on all platforms.

The save-state functionality depends on the open-source FBPP (File Based Player Prefs) solution, which has been tested on Windows, MacOS, Linux, iOS and Android. Extending it to work on other platforms will likely be straightforward for someone porting a game for those platforms.

License

LayerProcGen is licensed under the Mozilla Public License, v. 2.0.

You can read a summary here. In short: If you make changes/improvements to LayerProcGen, you must share those for free with the community. But the rest of the source code for your game or application is not subject to this license, so there's nothing preventing you from creating proprietary and commercial games that use LayerProcGen.