ofxWFC3D - Wave Function Collapse 3D | Addon release

Hi all,

I just publish the first version of the Wave Function Collapse addon I created for OF.
Its base on Maxim Gumin’s algorith (https://github.com/mxgmn/WaveFunctionCollapse)
This implementation solves 3D spatial tiling and allows to create complex, mesh-based, generative structures.
I also implemented some extra functionalities.
https://github.com/action-script/ofxWFC3D

Let me know if you have feedback / suggestions.

7 Likes

I think some images may help people understand what you can do with it :slight_smile:

1 Like

Looks like a very cool algorithm to create generative 3D meshes :slight_smile:

I did some performance tests and for the first image (that’s the included simple example), in debug mode:

  • 5x5x5 ~2 seconds
  • 6x6x6 ~ 6 seconds
  • 7x7x7 ~ 13 seconds
  • 8x8x8 ~ 25 seconds

In release mode 8x8x8 is <2 seconds.

I wonder if the performance would benefit from not using nested vectors, but a linear vector accessed the same way we access the pixels array, which is linear even if it represents 2D data. Here an SO answer related to this:

Doing that should avoid 3-level nested loops calling .resize(). Or does the data structure need to be always resizable in any of the x, y, z dimensions? Maybe I’ll try to see what happens to performance when using plain arrays with hard coded dimensions. I guess it’s something you normally don’t need to change in real time, but compile time is fine.

With warnings enabled (C++ > Code Model > checks for almost everything) I see many warnings. Some related to int / size_t casting, but also a return that can’t be called and if conditions that can’t be met because size_t is never < 0. Do you have those warnings enabled? Or maybe you are not using QtCreator? I find them very useful to avoid errors and always try to have 0 warnings :slight_smile:

Do you have any links explaining how to write the xml? I don’t find it obvious by looking at the examples.

Congratulations and thanks for publishing it! I’m looking forward to create stuff with it.

Hi,

Thanks for the feedback,
Definitely the efficient single array (instead the nested 3D and 4D vectors) will be the next change in the library.

I’m not using QtCreator, I use vim and g++. But I saw the warnings due I use the -w flag. I just ignored the warnings because I was focus on finishing the implementation and get shomething running. I will also check them out and improve the code. Thanks for pointing it out.

Hi! I just tried the updated version. Much faster! In debug mode it went from 25 sec to 3 sec. In release it’s about half second in 8x8x8.

I still see the warnings there. I would be happy to send PRs when I have some time :slight_smile:

1 Like