00:04These are some dungeons from my upcoming game.
00:06They were not hand-placed. Rather, they were generated with a simple algorithm called Wave Function Collapse,
00:11which is a lot more simple than it sounds. Here's how it works.
00:15Create some tiles, I pre-rendered them in four rotations with Blender,
00:18and label their sockets. For example, floor, wall, canal.
00:23This lets the algorithm know which tiles can and can't connect to each other.
00:27Now, consider this 4x4 grid. With zero constraints, we can place any of our 286 tiles in any place on
00:34the grid.
00:35However, adding wall and corner constraints cuts our tile options down dramatically.
00:40We start by placing a tile in the square with the smallest number of possible options, which is a corner
00:44square.
00:45We have collapsed the Wave Function for that square by picking one tile.
00:49We then find the next square with the smallest number of tile options and pick a legal tile.
00:54We continue doing this for every square until we have no more empty places.
00:58Notice how, by the time we get to the end, some spaces have very few tile options, like this square
01:03that has one possible solution.
01:05It needs a canal join here and a wall here.
01:09The canal cannot bend right because it would dead end without an end cap, and so it must bend left
01:13and exit the wall.
01:15This highlights an important point regarding WFC, which is that if you want varied and interesting results, you need a
01:20lot of tiles.
01:22To create more realistic lighting, we use normal maps, which we can bake from Blender.
01:26And we also add a clutter pass to give the dungeon more detail.
01:30As you will have guessed, Wave Function Collapse extends to arbitrary size and shape.
01:36I'm not quite ready to release a demo for the real game where you can play through these dungeons.
01:40However, you can test this algorithm yourself on this demo app I made, which shows you the dungeon style my
01:46upcoming game, Seeing Eyes,
01:47WISHLIST NOW, will use.
01:50In the web app, you can generate dungeons, place your own tiles.
01:54With Autosolve enabled, this will change surrounding tiles to fit.
01:57Disable this if you want to break adjacency rules.
02:00You can also generate around your placed tiles.
02:02This is useful if you want a specific feature in your dungeon.
02:06You can control dungeon size, and shape, and adjust lighting and clutter.
02:11And Perturb, a feature I really like, which swaps any tile for a random tile, and autosolves the connecting pieces.
02:18If you love a dungeon overall, but dislike one area, this feature is useful.
02:23Using this tool has been foundational in tweaking the algorithm I use in the real game.
02:27Only by generating new seeds and observing the results quickly can I see which tiles need adding,
02:33and which algorithm weights need changing, substantially speeding up the rate of design iteration.
02:38I'll be dropping a bigger update soon on my trials and tribulations over the last few months.
02:43Thanks for listening.
02:44Please remember to subscribe, wishlist, and play with the demo.
Kommentare