Gaussian Splats
Gaussian Splatting library (@downdraft/engine/libraries/gaussian-splats)
Section titled “Gaussian Splatting library (@downdraft/engine/libraries/gaussian-splats)”A renderer-only engine library for rendering 3D Gaussian Splat scenes (INRIA .ply and .splat formats). Uses a Structure-of-Arrays (SoA) data layout for GPU-friendly uploads.
Architecture
Section titled “Architecture”The library is split into four modules, each implementing a phase of the splat rendering pipeline:
-
Parser (
parser.ts) — Parses INRIA PLY and.splatfiles into aGaussianSplatDataSoA structure:position,scale,rotation,color(with opacity sigmoid baked into alpha), andshCoeffs(f_rest SH coefficients). Supports SH degrees 0-3. -
GPU radix sort (
gpu-sort.ts) —GpuSplatSortersorts splats back-to-front by camera distance using a GPU radix sort (4-bit radix, 8 passes for u32 keys). BelowsortThreshold(default 8192), falls back to CPU merge sort. After sorting, compacts the splat buffer into sorted order via a compute pass. -
Spherical harmonics (
sh-eval.ts) —packShCoeffs()packs SH “rest” coefficients (degrees 1-3) from parsed data, truncated to the configuredshDegree.SH_EVAL_WGSLis a WGSL chunk inserted into the fragment shader that evaluates real spherical harmonics for view-dependent color. The DC color is already baked intoGaussianSplatData.colorby the parser; SH adds the view-dependent contribution. -
Tile-based rasterization (
tile-raster.ts) —TileRasterPipelineimplements an alternative render path: a compute pass bins splats into 16×16 screen-space tiles, then a full-screen-triangle fragment shader iterates over per-tile splat lists and alpha-blends back-to-front. This replaces the default instanced-quad approach. The global sort ensures per-tile splat order is correct without a separate per-tile sort.
Renderer integration
Section titled “Renderer integration”GaussianSplatRenderer orchestrates all four modules. The render path:
- Write camera uniforms (viewProj, cameraPos, resolution).
- Sort + compact splats (GPU radix sort or CPU fallback, every
sortFrequencyframes). - If
tileRasteris enabled: bin splats into tiles (compute) → draw full-screen triangle (per-pixel splat iteration). - Else: draw instanced quads (4 verts × N instances, with SH eval in fragment shader).
Config (GaussianSplatsLibConfig)
Section titled “Config (GaussianSplatsLibConfig)”| Field | Default | Description |
|---|---|---|
surfaceFormat | "bgra8unorm" | Surface texture format |
maxSplats | 1_000_000 | GPU sort buffer pre-allocation |
sortThreshold | 8192 | Below this count, use CPU sort |
sortFrequency | 1 | Sort every N frames |
shDegree | 0 | Max SH degree (0=DC only, 1-3=view-dependent) |
tileRaster | false | Use tile-based rasterization |
tileRasterOptions | {} | Tile size + max splats per tile |
Declarative usage
Section titled “Declarative usage”import { GaussianSplatsLib } from "@downdraft/engine/libraries/gaussian-splats";
startApp({ libraries: [[GaussianSplatsLib, { shDegree: 2, sortThreshold: 4096, tileRaster: true, }]], // ...});All in packages/engine/libraries/gaussian-splats/src/ — the four pipeline files above plus renderer.ts (orchestrator), library.ts (descriptor), sorter.ts (CPU fallback).