World builder


I’ve been experimenting with Wave function collapse (WFC) algorithm when @sozap’s comment made me wonder if I could generate a world with it.
Kenney’s cute models and Roo Walker’s playful music inspired me to make this video.

Just a handful of tiles are placed manually, everything else is filled in procedurally.

The algorithm is pretty straightforward (here’s a great explanation using sudoku as an example):

  • At the beginning every cell in grid can take any tile.
  • Then some cell is selected and one of the tiles available for this cell is choosen.
  • This choice affects cell’s neighbours (and neighbours of its neighbours).
  • It repeats until all cells have tiles selected or it fails (no appropriate tile found for the cell).

example_3x3

The grid is 158x97x21 cells. It wasn’t generated in one go. Unfortunately, the bigger the grid the more likely the algorithm will fail. So you split the desired grid in blocks that overlap each other. In my case blocks are 10-18 cells long/wide and 3-6 high.

The video does not show the generation sequence for artistic purposes. Here’s how it actually looks like.

sequence

There are 516 tiles (including rotations and mirroring) + 338 substitutes (used after the grid is generated).


The adjacency rules are calculated partially automatically (it is a number representing unique geometry+color of tile’s side).
There are sets of tiles that can only connect to each other.

One of the annoying generation issues was rivers going up and down. Adding inflow/outflow connection rule instead of just river solved the issue.

Other frustrating thing was houses tightly packed together. By adding orientation connection rule to fundament tile facades are no longer placed next to walls.

What I would’ve done differently is making roads and rivers with some other algorithm and filling the rest with WFC (to fix loops and disconnected roads).

Near the end of the project I decided to try new list data type (CGMatter and Cartesian Caramel videos were very helpful).
To compare apples to apples, I updated my point-based implementation. Interestingly, points and lists gave me the same performance, but were way faster then the previous one.

The most time consuming part was tuning tile weights for specific outcome, it is pretty hard to control.

Exploring this place is fascinating.




The question is - what’s my input in this project? I haven’t designed models, I haven’t invented the algorithm, the output although highly influenced by me is still generated and I don’t like the slot machine aspect of it. What I do like is making things with geometry nodes and it was a nice exercise.

Other useful resources in case someone would also like to learn about WFC:

33 Likes

This is amazing in many aspects, the video is very pleasing to watch the result is awesome, the explanations are very interesting and probably a great starting point for someone willing to look into that … And I’m not sure everyone would manage to pull that off, even tech saavy people, so frankly it can hardly become cooler than that… Maybe it could be fun to experiment with more complex models or crazier setup, but this is already a great demonstation of mastery in various fields !!

Keep up the good work and always happy to see your inspiring projects !

4 Likes

I think this is mind blowing and brilliantly presented. Extremely impressive concept.

2 Likes

beautiful work !

i love maps so much that i can just keep looking to it for hours !

3 Likes

@sozap @LazloWoodbine @alf0 @michaelcarter Thank you all so much for the kind words! :heart:

3 Likes

Eyecandy.

And its procedural!

11/10 !

2 Likes

You’re on the featured row! :+1:

2 Likes

Amazing work

1 Like

Thank you @bartv! :smiling_face:

@goorman :folded_hands:

1 Like

this is so satisfying to watch. look so cute . but i know this is complex

1 Like