Handwriting 3D Gaussian splats in code instead of scanning a scene
Anisotropic 3D Gaussian surfels placed along procedural shapes turn 200 lines of JavaScript into a real-time 35mm cinema diorama in WebGL 2—with zero polygon meshes or photogrammetry scans.
December 2, 2026 · Project · What is not yet established
Open it here Open Procedural Splat Studio →
Code-written 3D scenes usually betray themselves through razor-sharp triangle edges and UV-free flat planes, while 3D Gaussian Splatting is usually locked inside 50 MB photo scans you cannot edit by hand.
After seeing Eddie Lee’s rainy Los Angeles alley (shared by CF Changfeng) alongside Mert Cobanov’s pixel-art surfel viewer, I built an authoring studio alongside my Coin Laundry splat corner to test why procedural splats feel like painted film frames where procedural meshes feel sterile—continuing the optical instinct from simulating classic camera lenses from one photograph and lighting a wine glass with one lamp.
Three mechanisms carry the illusion:
- Tangent surfels as jittered brushstrokes. Parametric boxes, cylinders, and sinusoidal tin sheets supply only positions and surface normals; jittering each surfel’s position, tangent covariance, and 3D noise albedo turns flat geometry into pitted concrete and rusted sheet metal with soft grazing silhouettes.
- Mirrored 3D Gaussians for wet puddles. Instead of fragile screen-space reflections, bright neon, streetlight, and car surfels spawn mirrored Gaussians below
y = 0with horizontally broadened covariance, shining up through semi-translucent puddle surfels with true 3D parallax. - Sub-native 35mm halation and grain. Drawing into a low-resolution HDR framebuffer scatters red-orange CineStill 800T emulsion halation across neighboring pixels before adding silver-halide grain, binding discrete splats into one cohesive frame.
Inside the studio, orbit three procedural worlds (Koreatown Rain, Inokashira Crossing, Pier 9 Sodium Fog), slide continuously from soft Gaussians to hard pixel surfels, edit the live JavaScript scene script (⌘↵), drop in any .glb, .obj, .ply, or .splat file, or export standard 3DGS .ply and .splat binaries. Static shadow baking and single-plane y = 0 mirrors remain the main limits—try breaking or extending the live script and send critiques to @ziding.
Agent context: sources, method and working notes
EWA 3D-to-2D covariance projection and GPU pipeline
Every procedural surfel $i \in {1, \dots, N}$ is stored in four 1024 × R RGBA32F GPU textures (uCenterAlpha, uScaleFlag, uQuat, uColorParam) so geometry never re-uploads during camera motion:
- 3D covariance from tangent frame: Each surfel’s unit quaternion $q_i$ aligns its local $z$-axis with the analytic surface normal $N_i$ (
sz << sx, sy), giving $\Sigma_i = R(q_i),\operatorname{diag}(s_x^2, s_y^2, s_z^2),R(q_i)^\top$. - Perspective EWA projection (Zwicker et al. 2001, Kerbl et al. 2023): Transforming to view coordinates $t = W \mu_i + w_0$ ($z_c = -t_z > 0$) and evaluating the perspective Jacobian $J$ yields the screen-space covariance $$\Sigma_{2\text{D}} = J W \Sigma_i W^\top J^\top + 0.30,I_2 = \begin{bmatrix} a & b \ b & c \end{bmatrix}.$$ Closed-form eigenvalues $\lambda_{1,2}$ and unit eigenvectors $v_1, v_2$ orient each 4-vertex instanced quad along $\pm 2.75\sqrt{\lambda_1},v_1 \pm 2.75\sqrt{\lambda_2},v_2$, reducing the fragment quadratic form $\Delta u^\top \Sigma_{2\text{D}}^{-1}\Delta u$ identically to $\xi_x^2 + \xi_y^2$.
- 16-bit single-pass counting sort (
0.3–0.6 ms): View-space depths $z_c$ quantize into 65,536 back-to-front buckets in a zero-allocationUint32Array, uploading only the compactR32UIpermutation texture (texSubImage2D) when view direction shifts by $> 0.45^\circ$. - Planar 3D puddle mirror without raytracing: Emissive and lit surfels above $y = 0$ generate reflected Gaussians at $(x, -y, z)$ with reflected quaternion $(-q_x, q_y, -q_z, q_w)$ and vertical scale broadened by $1 + 0.48,y$. Because back-to-front sorting draws $y < 0$ mirror splats before the street at $y = 0$, setting street surfel opacity to $0.96 - 0.62,\text{puddle}(x, z)$ acts as a zero-cost spatial mask: dry curb and sidewalk occlude the virtual image while wet puddles transmit parallax-accurate reflections.
Built-in procedural worlds and measured performance
Measured in headless Chromium (Apple M-series Metal backend, 1440 × 900 viewport at 2× DPR, RGBA16F HDR FBO):
| Scene | Source lines (SplatKit JS) | Total 3D Gaussians | Compile + shadow bake | CPU depth sort | Export size (.splat / .ply) |
|---|---|---|---|---|---|
Koreatown Rain, 2:14 AM | ~285 lines | 100,376 | 50 ms | 0.5 ms | 3.13 MB / 6.64 MB |
Inokashira Crossing | ~115 lines | 64,920 | 34 ms | 0.3 ms | 2.02 MB / 4.29 MB |
Pier 9 Sodium Fog | ~95 lines | 64,880 | 33 ms | 0.3 ms | 2.01 MB / 4.28 MB |
FLAGS.WATER) and bobbing skiff (FLAGS.BOB).Interoperability and local file conversion
- Live LLM authoring (
Copy LLM Prompt Spec): The studio’s<details>script drawer exposes the exactSplatKitJavaScript generating each world plus a one-click prompt specification so any coding model (Gemini, GPT-6.2 Astra, Claude) can generate new scenes that compile in ~50 ms in the browser. - Mesh-to-surfel splatizer (
.glb/.obj) & 3DGS viewer (.ply/.splat): Dropping a binary glTF.glbor Wavefront.objonto the viewport area-weights triangle surfaces into 85,000 oriented tangent surfels locally on-device, bakes wet-night lighting and puddle mirrors, and grades them through the four film stocks (CineStill 800T,Kodak 5219,16-Bit + Bayer,Bleach Bypass). - Spec-compliant export:
Export .SPLATwrites standard 32-byte Antimatter15/Spark records;Export 3DGS .PLYwrites binary little-endian Inria 3DGS vertices (f_dc_0..2spherical-harmonic DC, logitopacity, logscale_0..2, and(qw, qx, qy, qz)rotation).
Critique or advance this
- Weakest premise: Procedural boxes, cylinders, and heightfields still require deliberate spatial coordinates in code—complex organic characters or crumpled drapery quickly hit diminishing returns compared with sculpting or scanning unless paired with smooth SDF booleans and marching-surfel extraction.
- Concrete extensions (< 2 minutes to start in
splat-kit.js):- Smooth SDF surface-relaxation sampler: Add
kit.sampleSdf(fn, bounds, spacing)using 3-step gradient projection $p \leftarrow p - f(p)\nabla f(p)/|\nabla f(p)|^2$ so arbitrary smooth-unionsmincreature and vehicle SDFs automatically populate uniform tangent surfels. - Degree-1 spherical harmonics (
SH1) view-dependent wet glints: Export 9 additionalf_rest_0..8coefficients inexportGaussianPlyso exported.plyscenes carry directional specular sheen into external Three.js, Spark, and Blender viewers.
- Smooth SDF surface-relaxation sampler: Add