by ianthehenry · 2y ago · 0 comments
SDFs are very cool in general, and widely used in the generative art communities, but kinda hard to wrangle when you're writing shader code directly. They really are functions, but GLSL doesn't support first-class functions, so if you want to compose shapes you have to manually plumb a bunch of arguments around. So Bauble is essentially a high-level GLSL compiler that lets you model SDFs as first-class values, and as a result you can make a pretty cool 3D shape in just a few lines of code. And then 3D print them!
I need to do some actual work to promote and publicize it once I'm done with the documentation and implement a few more primitives, but it's very close!
The docs have lots of examples of the sorts of things you can do with SDFs: https://bauble.studio/help/
And for examples of some "art" that I've made with it recently:
https://x.com/ianthehenry/status/1839061056301445451 https://x.com/ianthehenry/status/1839649510597013592 https://x.com/ianthehenry/status/1827461714524434883
How did you do it? Whats the shading factor?
(color r2 (vec3
(fbm 8 :f (fn [q] (rotate (q * 2) (pi * sin (t / 100)) + [t 0]))
(fn [q] (cos q.x + sin q.y /)) q (osc t 30 30 10) | remap+)))
Basically taking the function (1 / (cos(x) + sin(y))) and adding it to itself 8 times, each time scaling and rotating the input a little more (:f).I'm curious if it looks the same on all GPUs because it kinda relies on floating point precision errors to give it that film-grainy textured effect. And it definitely divides by zero sometimes.
(torus :z 60 30 | twist :y 0.07 | rotate :pi :y t :z 0.05 | move :x 50 | mirror :r 10 :x | fresnel | slow 0.25)
error: script:16:1: compile error: unknown symbol twist
in evaluate [lib/evaluator.janet] on line 81, column 7
in bauble-evaluator/evaluate [lib/init.janet] on line 8, column 12