wavefunctioncollapse icon indicating copy to clipboard operation
wavefunctioncollapse copied to clipboard

Is it possible to specify colors at positions in the overlapping model?

Open Keristero opened this issue 6 years ago • 2 comments

I always want my output to be bordered by a specific color, I've tried modifying the array returned by model.graphics() between iterations, but that clearly is not the way to do this... is there any way to do this currently? something like.

let model = new OverlappingModel(data, width, etc);
let startingArr = model.gaphics();
//Set RGB of first pixel to (0,0,0)
startingArr[0] = 0;
startingArr[1] = 0;
startingArr[2] = 0;
//Overwrite existing graphics array
model.setGraphics(startingArr);

Keristero avatar Jul 21 '19 00:07 Keristero

Currently there is no way to do this (whether in this port or in the original C# library/algo), and implementing this would not be trivial. The graphics array is only generated when requested, internally the algorithm works by segmenting the example pattern (data) in smaller chunks/patterns and storing the probability for each pixels of those patterns to be a correct choice for each pixels of the result image.

I'm leaving this issue open as it would be an interesting feature to try and implement.

In the mean time you might be interested to check Brian Bucklew's GDC 2019 presentation on how the algorithm is used and controlled in Cave of Qud. The "texture mode" Brian mentions is the overlapping model. Also, if you're still testing the water for your own procedural content generation system, you might want to check the js/webgl port of the ConvChain algorithm it's fast and supports pre-set "immutable cells", but this algorithm only handles 1bit/black and white maps. Hopefully you'll find a suitable solution for your problem at hand.

kchapelier avatar Jul 21 '19 08:07 kchapelier

Thanks, I'll certainly watch that talk and check out ConvChain. In the meantime I've hacked together a solution involving combining several of the same output image and cropping to the largest contiguous image. Very slow but it sort of works

Keristero avatar Jul 21 '19 11:07 Keristero