WaveFunctionCollapse builds output images that reuse only local pixel patterns found in a sample input. It supports bitmap synthesis and tile-based level layouts for games and art.
Overview
WaveFunctionCollapse is a program that generates bitmaps resembling a provided input image at a local level. Outputs may only contain N×N pixel patterns that appear in the sample, and over many runs the frequency of patterns should stay close to what the input shows. The method starts from an unobserved grid, repeatedly collapses low-entropy regions to definite colors, and propagates constraints until the image is fully determined or hits a contradiction.
Beyond flat images, the same ideas extend to tilemaps through a simple tiled model with adjacency rules, symmetry helpers for tilesets, and support for constraints so partial human-made layouts can be completed automatically. Higher-dimensional voxel-style models and combinations with other synthesis methods are further applications.
You can build the reference implementation from source with .NET Core on Windows, Linux, or macOS, download a Windows release, use an interactive build from itch.io, or run a version in the browser. The algorithm has been reimplemented in many languages and adapted into game engines such as Unity, Unreal Engine 5, Godot 4, and Houdini. Commercial and indie titles including Bad North, Caves of Qud, Townscaper, and others have used it for procedural content.
The approach is approximate rather than exact quantum simulation; contradictions can stop a run because related decision problems are hard in the general case, though failures are uncommon in practice. Related write-ups, demos, and community ports support deeper study.
Key features
- Bitmap generation from one sample image
- Tilemap model with adjacency constraints
- Observation and propagation collapse cycle
- Optional pattern rotations and reflections
- Constraint and autocomplete support
- Simple tiled and overlapping models
- Console reference implementation
- Browser and packaged graphical builds
Use cases
- Procedural game levels and maps
- Texture-style pattern synthesis
- Tileset-based world building
- Voxel and higher-dimensional layouts
- Research and teaching procedural methods