实时编程光线步进
marching.js,Charlie Roberts,2018 年

正在布展…
它是怎么做的
- 第 1 步JS 对象树描述 SDF 图元与布尔/平滑并集操作
- 第 2 步库把对象树编译为 GLSL 距离函数并插入光线步进模板
- 第 3 步支持 FFT 输入,把音频能量绑定到参数
- 第 4 步Playground 内置编辑器,Ctrl+Enter 即时重编译
复刻配方
一段技术配方,可以直接交给 AI 编程助手,也可以自己照着写。想指定技术栈、位置和性能预算,就把它加入实现方案。
Define a tiny JS DSL where each primitive (sphere, box, torus) and operator (union, smooth union, repeat, twist) is an object that can emit a GLSL expression string. Walk the object tree to generate a map(p) distance function and insert it into a standard sphere-tracing fragment shader with normal estimation and soft shadows. Expose uniforms for any numeric parameter so they can be animated from JS or driven by WebAudio analyser bands without recompiling. Put a code editor beside the canvas and re-evaluate on a keyboard shortcut.


