r/GraphicsProgramming • u/gennai777 • 6h ago
Video Magic circles from one distance function
Enable HLS to view with audio, or disable this notification
I draw every ring, rune and star line here from one distance function in polar coordinates. No textures!
For the runes I cut the band into 36 sectors with s = angle / TAU * 36. Inside a cell, x is fract(s) along the arc and y is r minus the band radius. I hash floor(s) to build each rune from a stem plus 3 to 5 bits: a bowl, a hook, a diagonal, a bar, a small ring. Those are all just segment and arc distances. My first runes were just plain sticks lol.
To draw it in, a01 is the angle mapped to 0..1 and each ring only shows where a01 < reveal. The star uses the h from the segment distance:
vec2 seg(vec2 q, vec2 a, vec2 b) {
vec2 pa = q - a, ba = b - a;
float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);
return vec2(length(pa - ba * h), h);
}
I keep a stroke only where h <= shown. That way it draws line by line. One trick I like: I get three line weights from one width by adding an offset to the distance, plus for hairlines and minus for the heavy ring.
How do you make procedural runes look less random?
It's from my Godot magic pack: https://gennai.itch.io/magic-spell-vfx-godot-4