top of page
Schermafbeelding 2024-02-07 180657.png

3d wave function collapse

An implementation of the Wave Function Collapse algorithm to generate cityscapes in 3D.

​

This algorithm works with a grid of cells that contain all possible states of a cell. Iterating through the cells, one cell at a time gets their state assigned and their possible states reduced to one. This change reduces the amount of states a neighbouring cell can have. Like a wave running through the grid, possibilities get reduced and cells get collapsed, until eventually the whole grid is collapsed.

4244.834.png

2D to 3D

To better understand the algorithm I first created a 2D prototype in Processing. The difference in complexity the third layer brought was quite unexpected.

Schermafbeelding 2024-02-06 220641.png

Iteration

Working through one axis at a time, after many bugs and subsequent bugfixes the algorithm worked.

Schermafbeelding 2024-02-07 173233.png

visualisation

With a more visually appealing tileset and some controls, a demo is now available that allows anyone to generate a simple cityscape with this algorithm.

bottom of page