r/creativecoding • u/Single-Lab-5692 • Oct 13 '26
A Nebula Rearranged
A variation of the 'generalized rainbow smoke algorithm'.
The algorithm is made of 2 breadth-first-searches (BFS), one choosing colors and the other placing them. This video shows the 'placement BFS' constructing the image. Due to random sampling, the 'color BFS' can't always find an unused color, in which case it gives up, leaving a hole.
Once the placement BFS runs out of places to fill, the color BFS resets and the process is repeated on the unfilled holes. The choice of how to handle these points has a big impact on the final image and it's the main thing that's different here compared to the original 'generalized' algorithm (afaik).
The animating effect comes from 'rolling' the image used by the color BFS, (the Rosette Nebula in this case), with the speed of the animation being proportional to the number of unplaced pixels remaining.
A longer 4K loop is also available:
https://youtu.be/ZzxQXPHAVn4?si=ud_53baLFXAYlNpX
Links for more info about the algorithm:
3
u/labmaster_q Oct 13 '26
'Tis beautiful, can we get the code?
1
u/gnome_of_the_damned Oct 13 '26
wonderful work! would love to see the code!
1
u/Perfect_Answer_4095 Oct 14 '26
wow mesmerizing
1
u/johndavid_artist Oct 15 '26
Tying the roll speed to the number of unplaced pixels is a lovely touch, the image eases into place as the holes close. On the second pass, do the holes take the nearest unused color or a fresh random sample?
1
u/Ramillionquay Oct 17 '26
beautiful!
1
u/hardikgodhaa Oct 20 '26
This is really cool, would love to try something like this myself.
0
u/[deleted] Oct 17 '26
[removed] — view removed comment