Pixel-art Gaussian splat dioramas: scenes modelled as SDFs in plain JavaScript, Gaussian splats on their surfaces, and a pixel-art pass in WebGL2. A skill that makes new dioramas by modelling, rendering, looking and refining.
Five small worlds, each a few dozen SDF shapes in plain JavaScript, covered in 35,000 to 50,000 Gaussian splats and
drawn through a pixel-art pass: one palette per scene, two-colour dithering, dark outlines. They render live in WebGL2,
from one HTML file with no dependencies. Drag a scene to turn it, and press P to see the splats without the pixel pass.
The idea is @JungleSilicon's: make SDFs, place Gaussian
splats along their surfaces, then run a pixel-art post-process. This repo is our own take on that recipe, written from
scratch, with a skill to make more.
how it works.
1 · sdf shapes. Each scene is a few dozen signed distance functions: ellipsoids, boxes, cones, tapered capsules, smooth unions, noise. the fox is 14 shapes
2 · splats on the surface. An octree walks each shape's distance field and drops a splat about every 2 px, oriented along the surface. 35,656 splats in this one
3 · gaussian splats. Each splat is a flat 3D Gaussian, lit, shadowed and blended back to front every frame. what you see with the pixel pass off
4 · the pixel pass. About 216 px tall, a hand-made palette, two-colour dithering, outlines on depth edges. 384 x 216, scaled up with hard edges
Splats from distance fields. For each shape, an octree skips space the distance field says is empty and, in each
surface cell, steps a point onto the surface along the gradient. Splats buried inside another shape are dropped.
Ambient occlusion comes from the distance field too.
Splatting. Each splat has two radii in the surface and a thin third, projected to a 2D ellipse every frame (the
EWA Jacobian), counting-sorted back to front on the CPU and blended. Light is per splat: a key light with a shadow
map drawn from the splats themselves, sky and ground fill, up to four point lights, rim and specular.
The pixel pass. The scene renders at about 216 px tall and scales up with hard edges. An opaque depth pass of the
same splats gives the outlines. Each pixel maps to the scene's palette in OKLab: the nearest colour and the one that
best brackets it, dithered on a 4x4 Bayer grid. Surfaces only get flat colour or a 50% checker.
Motion. Groups move with rigid poses and four procedural deforms (sway, water, swim, breathe). Particles do
flames, embers, smoke, fireflies, rain and light beams.
One file.index.html is all of it. Each scene builds in a web worker in about half a second.
make your own.
git clone https://github.com/patch-gg/pixel-splats && cd pixel-splats
python3 -m http.server 8000 # then open http://localhost:8000
Drag to turn a scene, scroll to zoom, double-click to reset. The arrow keys change scene, P turns the pixel pass off
and on, and space pauses. #campfire, #koi-pond and so on open one scene.
A scene is one block in index.html: its shapes and materials, palette, lights, camera and animation.
skills/pixel-splats/REFERENCE.md has the whole API. Copy the closest scene, change
it, and look at it:
node tools/shot.mjs campfire --angles 3 # three views at 4x, in out/shots/
node tools/shot.mjs mimic --crop 150,40,90,70 # a close look at part of the frame
node tools/shot.mjs geode --mode clay --size 768x432 --scale 1 # the shapes alone
node tools/film.mjs lighthouse --seconds 8 # an MP4 at 1920x1080 (or --out out/lighthouse.gif)