mr-highball / wfc

wave function collapse algorithm
MIT License
6 stars 2 forks source link

3D demo with simple building kit #3

Open mr-highball opened 2 years ago

mr-highball commented 2 years ago

spawned from this reddit post. we'll see about handling the world generation along with attempting to get around the invalid states

image source image

lynchjonathan commented 2 years ago

Here are the meshes in one fbx simpleBuildingProtoSet.zip

mr-highball commented 2 years ago

think this about sums up the constraints that I'll be following and I made issue-3 into a branch I'll be working on

should be the full parts list with all the rotations explicitly written out.

basic constraints

naming convention

gr_000 (ground)

bw_000 (base wall 0 rotation)
bw_090 (base wall 90 rotation)
bw_180 (base wall 180 rotation)
bw_270 (base wall 270 rotation)

br_000 (base corner 0 rotation)
br_090 (base corner 90 rotation)
br_180 (base corner 180 rotation)
br_270 (base corner 270 rotation)

mw_000 (mid wall 0 rotation)
mw_090 (mid wall 90 rotation)
mw_180 (mid wall 180 rotation)
mw_270 (mid wall 270 rotation)

mr_000 (mid corner 0 rotation)
mr_090 (mid corner 90 rotation)
mr_180 (mid corner 180 rotation)
mr_270 (mid corner 270 rotation)

tw_000 (top wall 0 rotation)
tw_090 (top wall 90 rotation)
tw_180 (top wall 180 rotation)
tw_270 (top wall 270 rotation)

tr_000 (top corner 0 rotation)
tr_090 (top corner 90 rotation)
tr_180 (top corner 180 rotation)
tr_270 (top corner 270 rotation)

rw_000 (roof wall 0 rotation)
rw_090 (roof wall 90 rotation)
rw_180 (roof wall 180 rotation)
rw_270 (roof wall 270 rotation)

rr_000 (roof corner 0 rotation)
rr_090 (roof corner 90 rotation)
rr_180 (roof corner 180 rotation)
rr_270 (roof corner 270 rotation)

rf_000 (roof)

em_000 (empty space block in between buildings)
mr-highball commented 2 years ago

@lynchjonathan testing out some things 1 dimension at a time and clearly have some things to work out (different symbols / colors mean walls/corners/grass etc.. and what I'm getting as output isn't sensible and has many invalid states). image

this has been a good challenge to poke holes into my implementation 😅 still working on things and will keep you posted

lynchjonathan commented 2 years ago

Yeah I'll need to be more explicit with the constraints between different pieces of the collapse it seems. That on its own will make sure prototypes connect appropriately in most cases but I have gone in and implemented both a blacklisting function per face and a max and minimum height property for each prototype. Telling ground it cannot be stacked on top of ground but its okay horizontally already takes care of the stacked replica towns.

Seems we're both getting some good feedback here too lol

Ultimately though I think the invalid state is just as valid as any other state and that is a hard rule for wfc. It was a little naive of me to think I could slap some meshes in and make it build a town. By accepting invalid as just another constraint to satisfy I can use blacklists to make sure the perceived invalid constraints are respected.

mr-highball commented 2 years ago

@lynchjonathan yes perceived invalid is a great takeaway here. Conceptually it's very sensible to think that throwing some meshes at wfc should "just work" but the fact is... it's not that simple haha

This is something I've been meaning to do for a while now but got sidetracked with going down a path of music generation with wfc. I've got some ideas with how to get this working properly but I want to make sure it makes sense in a generalized sense, so I need to keep playing around in text to make sure it'll translate to 3D.