Show HN: Make 3D art in your browser using Lisp and math (bauble.studio)
Bauble is based on raymarching signed distance functions, which are kind of like... 3D vector art? They're pretty common in the procedural art community and you can do some amazing things with them, but normally writing SDFs means writing low-level shader code.
I wanted to play with SDFs, but I found it very frustrating to translate "I want to rotate this" into "okay, that means I have to construct a rotation matrix, and then apply it to the current point, and then evaluate the shape...". So I made a high-level Janet DSL that compiles down to GLSL shader code so I could more easily play with mathematically defined shapes.
For more about SDFs, this mind-blowing video is what got me interested in the first place, and shows you what they're capable of in the hands of an expert: https://www.youtube.com/watch?v=8--5LwHRhjk
40 comments
[ 256 ms ] story [ 1636 ms ] threadI want to make a live tutorial, I'm thinking about creating a static site generator to generate the same kind of demo you have here.
Long-term I think I'd rather break this out into a separate page with multiple canvases inline in the text -- so you can more easily scan through it/go back to previous sections -- but I was lazy and this was the easiest way to get it done.
Also, this is just a static site. With hand-written HTML because I've been too lazy to configure a static site generator yet...
https://codemirror.net/
https://github.com/ianthehenry/codemirror-lang-janet
I went with CodeMirror after reading this post: https://blog.replit.com/codemirror and I've been super happy with it.
libfive is only concerned with geometry, though, so you can't do any of the coloring/shading/procedural graphics stuff. And no animations. I think of Bauble as closer to Shadertoy than libfive in purpose, although they appear very similar.
Do you think this can be used for live coding visuals?
I'd love to use it together with Glicol(https://glicol.org).
So far I have tested Hydra and p5.js; they can be used as CDN link or NPM packages.
Look forward to its progress.
Apart from that big question mark I think it would be very suitable for livecoding visuals, as you can write some impressive effects with very little code. Easy CSS change to make the canvas full-screen and like overlay the code on top of it. That's a thing that livecoders do, right?
https://youtu.be/iKj7IibG0OU
I think both Hydra and p5.js render things to a <canvas>, which is probably the same as what your demo does, right?
Then we just need to set some CSS for the Canvas to make it full screen and hide behind the code editor.
I was imagining something where you switch between coding audio and visuals on the fly -- which is still totally possible, but would require a bit of work to get them talking to each other.
I post the hydra link here. There are lots of demo there:
https://hydra.ojack.xyz/
So far I haven't tried to make them talk such as sync the beat etc. But I think with web worker it is doable.
So I'm guessing that the best case scenario for you is to import Bauble as like a normal JavaScript dependency, and then use the editor built into the Glicol UI to write scripts, and then just call like Bauble.compile(canvas, script). Right?
Bauble doesn't really know how to be embedded in another page right now -- it's more like an app than a library. But it would be possible to extract the core parts. It's a little tricky because it uses WASM, so it kinda needs to load itself a little specially, but I'm sure there's some way around that.
Would be cool to sync something like this to music! https://twitter.com/ianthehenry/status/1567228698373533696 (ignore the terrible lighting. lights are coming one day)
In terms of translating audio to variables useful for driving visuals, ColorChord is getting some traction; it's an algorithm that powers a technology called AudioLink, which is growing beyond its origins in VRChat.
https://github.com/cnlohr/colorchord
https://www.colorchord.net/
https://github.com/llealloo/vrc-udon-audio-link
https://github.com/llealloo/vrc-udon-audio-link/blob/master/...
It's LISP, and has libraries and examples for live-coding + music generation + interfacing with the web, hardware, etc.
Small but passionate and helpful community. I've done some amazing stuff with it, live visuals + song generation on MIDI hardware synths using realtime web data like local weather, etc.
https://extemporelang.github.io/
BTW, it's a really nice example of the possibilities of Lisp, which reminds me to refresh my memories and start coding in Lisp again.
https://www.glslsandbox.com/?page=4
and
https://www.shadertoy.com
Unfortunately glslsanbox is not moderated very well so there's lots of spammy garbage there but also lots of really great stuff.
https://shaderpark.com/