When water freezes it can generate beautiful patterns. It happens most famously with snowflakes but we also see them on, say, frozen windshields.
This happens with metals, too, and in fact I first learned about this back when the company I worked for rebranded to “Galvanize.” I thought it’d be neat to write an algorithm to generate the same look.
Turns out it’s pretty tough.
So far my algorithm checks whether a pixel has any neighbours. Neighbours that are aligned with the direction of growth will increase the probability of the crystal being formed there where as neighbours that are not aligned will reduce the probability (as opposed to just leaving it at zero).
The number of directions the crystal grows is indicated by an “anisotropy” parameter. The image above uses an anisotropy value of 4 so it’s growing in the cardinal directions.
That value isn’t very flexible right now, though. If I change it to anisotrophy=6 I don’t get a nice snowflake I get this mostly sideways output:
Here’s what it looks like with anisotrophy=3.
The pixel grid is the problem. It naturally supports growth in the cardinal directions but any other angle doesn’t work so well.
I have an idea for reducing this bias but it’ll have to wait for next time.
Meanwhile, here’s another output with anisotropy=4.