Periodic Spaces

https://news.ycombinator.com/rss Hits: 6
Summary

One of my favorite SDF techniques is domain repetition: (def eye-center [35 82 62]) (def eyes (ball 39 | move eye-center | mirror x :r 10)) (def eye-angle [0 0 0]) (defn pupils [target] (def left-pupil (ball 15 | shade black | move [39 0 0] | align x target | move eye-center )) (def right-pupil (ball 15 | shade black | move [39 0 0] | align x target | move [-1 1 1 * eye-center] )) (union left-pupil right-pupil)) (defn get-target [seed i] (hash3 seed i | remap- + [0 0 2] | normalize)) (defn eye-target [seed] (def base (t + hash 30 seed * hash 20 seed)) (def frame (floor base + 100)) (mix (get-target seed frame) (get-target seed (frame + 1)) (ss (fract base) 0.49 0.51))) (def anim (osc t 7 | ss 0.2 0.8)) (union :r 50 (ball [100 150 100] | move [0 7 3]) | shade sky | union (expand eyes 20 | move [0 1 -43]) :r 10 | subtract :r 10 eyes | union (eyes | shade white | union-color (pupils (eye-target $i))) | union (box :r 17 [(ss p.y -44 44 17 33) 44 17] | morph (ball [29 44 17]) | rotate x 2.92 | move [0 12 100] | shade orange) | tile: $i [(anim * 400) (anim * 500) (anim * 500)] :limit [(anim * 10000) 8 (anim * 10000)] | union (ground -150 | shade white) | scale 0.25 | scale (ss anim 0 1 1 0.2) | rotate y 0.45 x -0.33 z 0.08) It’s a great party trick that lets you render an infinite number of shapes in real-time, with soft shadows and ambient occlusion and all the other nice things that SDFs give you. It seemed like magic to me when I first saw it, and I suppose it still does – albeit in a different way. The trick that makes this possible is that you aren’t evaluating “an infinite number of shapes.” As each ray marches through the scene, it only evaluates one shape at a time. Let’s look at a 2D slice of that scene: (def eye-center [35 82 62]) (def eyes (ball 39 | move eye-center | mirror x :r 10)) (def eye-angle [0 0 0]) (defn pupils [target] (def left-pupil (ball 15 | color black | move [39 0 0] | align x target | move eye-center )) (def right-pupil (ball 15 | color black ...

First seen: 2025-12-09 08:28

Last seen: 2025-12-09 13:29