← Ziding Zhang

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


The interactive for “Handwriting 3D Gaussian splats in code instead of scanning a scene”, as it first appears. Open it here
Three rainy street scenes built from Gaussians placed by code. Change the scene, the camera path and the film stock. On its own page

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.

Nocturnal rain-soaked Los Angeles storefront and parked 1980s pewter sedan rendered from 100,400 procedural 3D Gaussian splats with glowing pink Korean karaoke neon, corrugated awning, and 35mm film grain.
Koreatown Rain, 2:14 AM: 100,400 procedural 3D Gaussian splats compiled in 50 ms in the browser—zero polygon meshes, textures, or scanned point clouds.

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:

  1. 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.
  2. Mirrored 3D Gaussians for wet puddles. Instead of fragile screen-space reflections, bright neon, streetlight, and car surfels spawn mirrored Gaussians below y = 0 with horizontally broadened covariance, shining up through semi-translucent puddle surfels with true 3D parallax.
  3. 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.
Split-screen wipe of the rainy alley: left half reveals 100,400 individual 3-sigma oriented 2D covariance ellipses; right half shows the graded 35mm CineStill 800T film render.
Left: the underlying 100,400 oriented 3σ covariance ellipses with falloff disabled. Right: the same splats after EWA Gaussian blending, wet-mirror reflection, halation, and 35mm grain.

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-allocation Uint32Array, uploading only the compact R32UI permutation 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):

SceneSource lines (SplatKit JS)Total 3D GaussiansCompile + shadow bakeCPU depth sortExport size (.splat / .ply)
Koreatown Rain, 2:14 AM~285 lines100,37650 ms0.5 ms3.13 MB / 6.64 MB
Inokashira Crossing~115 lines64,92034 ms0.3 ms2.02 MB / 4.29 MB
Pier 9 Sodium Fog~95 lines64,88033 ms0.3 ms2.01 MB / 4.28 MB
Inokashira railroad crossing in heavy rain rendered in procedural 3D Gaussian splats, showing glowing cyan and red vending machines, striped barrier, and flashing red beacon.
Inokashira Crossing: alternating GPU crossing beacons, wet steel rails, and vending-machine halation.
Pier 9 timber dock and moored wooden skiff bobbing on harbor swell under a warm golden lighthouse fog lantern in procedural 3D Gaussian splats.
Pier 9 Sodium Fog: dynamic GPU harbor swell (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 exact SplatKit JavaScript 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 .glb or Wavefront .obj onto 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 .SPLAT writes standard 32-byte Antimatter15/Spark records; Export 3DGS .PLY writes binary little-endian Inria 3DGS vertices (f_dc_0..2 spherical-harmonic DC, logit opacity, log scale_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):
    1. 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-union smin creature and vehicle SDFs automatically populate uniform tangent surfels.
    2. Degree-1 spherical harmonics (SH1) view-dependent wet glints: Export 9 additional f_rest_0..8 coefficients in exportGaussianPly so exported .ply scenes carry directional specular sheen into external Three.js, Spark, and Blender viewers.

Have an answer, a counterexample, or a story? See Talk to me for open questions and live trials.

Credits: Ziding Zhang with Gemini 4 Carbon. Inspired by Eddie Lee's (@eddietree) Three.js + real-time 3DGS rain dioramas (via @cfenghub) and Mert Cobanov's pixelart-gaussiansplat.