Gaussian Splatting From Zero · Episode 08

Making It Fast

Making It Fast is Episode 08 of Gaussian Splatting From Zero, a MasterAllArts free interactive lesson for artists learning creative 3D on the web.

Part of the MasterAllArts Creative 3D Roadmap .

Episode 08 · Gaussian Splatting From Zero · Season 1 Finale

You've built a complete Gaussian splat renderer: covariance projection, alpha blending, a back-to-front sort, view-dependent color, a real file loader. This finale makes it scale — to a quarter-million splats at 60fps — and proves it plays nicely with the rest of the world by dropping a solid, lit Three.js mesh straight into the splat scene. Push the count slider, flip between the high-throughput opaque mode and the high-quality sorted mode, and watch the moon pass behind and in front of the planet with correct occlusion. This is the whole season in one canvas.

—
drag to orbit · scroll to zoom
opaque · 80k splats
A lit mesh moon orbits an 80k-splat planet — both depth-composite correctly.

Where the milliseconds go

A splat renderer spends its frame in four places. Know which one is your bottleneck before you optimize — guessing wrong is how people make splat viewers slower:

CostScales withLever
Sortingsplat countcounting sort, throttle, Web Worker, GPU radix
Vertex / projectionsplat countfrustum cull, LOD, fewer splats
Fill rate / overdrawsplat size on screen × overlapdiscard early, tighter Gaussians, cull tiny splats
Upload bandwidthre-sorted bytes/frameindex-only sort, don't re-upload static data

The HUD in the demo shows fps, live splat count, and the sort time in milliseconds. Drag the count up in sorted mode and watch the sort time climb — that's why production viewers move the sort off the main thread. Switch to opaque mode and the sort cost vanishes entirely, because opaque splats don't need ordering.

Two render modes, two trade-offs

Opaque (the cheat that scales)

For dense, surface-like captures you can skip transparency altogether: alpha-test each splat (keep the bright core, discard the soft rim) and let the depth buffer sort everything for free, exactly like triangles. No CPU sort, no blend order, so it scales to hundreds of thousands of splats trivially. You lose the soft translucent edges and any real see-through, but for solid scenes it's often indistinguishable — and it's how you hit big counts on weak hardware.

Sorted-transparent (the real thing)

For correct soft edges, glass, foliage, and smoke you need the Episode 04–05 pipeline: premultiplied "over" blending, back-to-front sort, no depth write. Gorgeous, and the sort caps your count. The demo limits this mode to keep the main-thread sort honest; a worker-based sort would lift that cap.

Frustum culling and LOD: don't draw what you can't see

The cheapest splat is the one you skip. Two ideas carry most of the win:

  • Frustum culling. During the sort, test each splat's center against the camera's six frustum planes and drop the ones outside. For a capture you're standing inside, that routinely halves the work — you only ever see a fraction of a room at once.
  • Level of detail. Far-away splats project to sub-pixel size; merge or drop them. Spark 2.0 and other modern viewers build an LOD tree so they can stream and render city-scale scenes by only ever resolving the splats near the camera. We'll meet streaming LOD in Season 2.

Splats with geometry: the depth handshake

Real apps aren't all splats — they have UI meshes, gizmos, characters, a floor. The moon in the demo is an ordinary THREE.Mesh with a MeshStandardMaterial and a light. Mixing the two correctly comes down to the depth buffer:

// opaque geometry draws first and WRITES depth
moon.material.depthWrite = true;

// transparent splats draw after, TEST depth but don't write it
splat.material.depthTest  = true;   // so the moon can hide splats behind it
splat.material.depthWrite = false;  // so splats still blend among themselves

Three.js already renders opaque before transparent, so the moon lays down depth, and splats behind it are correctly rejected while splats in front blend over it. Toggle the moon and orbit until it swings behind the planet: in opaque-splat mode the planet cleanly occludes it; bring it in front and it occludes the planet. That two-way occlusion — splats and triangles in one depth buffer — is what makes splats usable in a real product instead of a demo reel.

The production checklist

  • Sort on a Web Worker, with the data in a texture and only an index array re-uploaded. Never block the render thread.
  • Frustum-cull and LOD before you optimize anything else; not-drawing beats fast-drawing.
  • Cap device pixel ratio and splat count on mobile; fill rate is the silent killer on phones.
  • Stream large scenes — show a coarse splat set immediately, refine as bytes arrive, instead of a 30-second white screen.
  • Profile the right bucket. If the HUD says sort is 0.3ms and you're still at 20fps, your problem is overdraw, not sorting.

What you built

Eight episodes ago a Gaussian splat was a buzzword. Now it's a data structure you can render, blend, sort, color, load, and scale — from scratch, in a few hundred lines of Three.js, holding 60fps on a laptop. You can read antimatter15's viewer, gsplat.js, or Spark and recognize every moving part, because you've written each one. That's the goal of Season 1: not to use a splat library, but to be able to write one.

Common pitfalls

  • fps tanks only in sorted mode at high count. Main-thread sort + re-upload. Move to a worker / index-texture, or use opaque mode for dense scenes.
  • The mesh and splats z-fight or one ignores the other. Depth flags wrong: opaque geometry writes depth, transparent splats test-but-don't-write.
  • Great on desktop, slideshow on phone. Overdraw + pixel ratio. Clamp setPixelRatio(Math.min(dpr, 2)) and cut splat count.
  • Regenerating splats on every slider tick hitches. Generate the maximum once and just change instanceCount to draw a prefix — what this demo does.
  • Opaque mode looks "bitten" at edges. That's the alpha-test discarding the soft rim; it's the price of skipping the sort. Use sorted mode where edges matter.

Exercises

  1. Add real frustum culling in the sort loop (six plane tests) and show "visible / total" in the HUD. Orbit until half the planet is off-screen and watch the visible count drop.
  2. Move the counting sort to a Web Worker; post the view matrix in, transfer the order array back. Compare sorted-mode fps before and after.
  3. Give the moon a splat capture instead of a mesh and confirm two splat objects share one global depth sort (they must be merged or interleaved — splatting has no "objects").
  4. Add a ground plane mesh with a shadow and place the planet on it. Getting splats to cast or receive shadows is a real open problem — note where it breaks.

Season 2 awaits

That's Season 1 — the renderer, built from zero. Season 2 leaves the procedural sandbox: capturing your own scenes with a phone or COLMAP, the tooling landscape (SuperSplat, Spark, Postshot, Blender), editing and cleanup, compression (.spz and friends), splats in real apps, applying your shader skills to splats — and the episode everyone asks for, animated & 4D Gaussian splats: volumetric video you can fly through. See you there.