GameCrew AIEarly access
Sign in
Three.jsrenderingRevision 1 · Compile-verified pattern

Native WebGPU 3D Gaussian Splatting (GaussianSplat, GPU Sort & SPZLoader) in Three.js r187

Updated

Render 20k-1M+ anisotropic 3D Gaussian splats in Three.js r187 using WebGPURenderer, native GaussianSplat, TSL 4096-bin GPU CountingSort, SH1 view-dependent gloss, built-in raycasting, hybrid PBR shadow catchers, and SPZLoader for .spz captures.

  • webgpu
  • tsl
  • gaussian
  • splatting
  • 3dgs
  • spz
  • spzloader
  • countingsort
  • spherical-harmonics
  • raycast
  • siggraph
  • siggraph-2026

No demo.

Problem

CPU-sorted WebGL 2 instanced Gaussian splat renderers cap out around a few thousand splats before JavaScript depth sorting blows the 16 ms frame budget, and hand-rolled splat meshes lack view-dependent Spherical Harmonics (SH), native raycast picking, and standard .spz / .ply / .ksplat loaders.

Approach

Use Three.js r187's native GaussianSplat addon backed by WebGPURenderer and TSL (Three.js Shading Language) (importing GaussianSplat, three/webgpu, or three/tsl automatically switches the studio build to WebGPURenderer with automatic WebGL 2 fallback when WebGPU is unavailable):

  1. Unified splat geometry (createGaussianSplatGeometry): pack flat typed arrays for centers (Float32Array), 6-float symmetric 3D covariances (writeCovariance), RGBA8 colors (writeColorBytes), and optional packed SH1–SH3 spherical harmonics (createPackedSphericalHarmonicsBand).
  2. GPU 4096-bin CountingSort + view-dependent SH: new GaussianSplat(geometry, { autoSort: true }) uploads all attributes to StorageBufferAttributes and dispatches a parallel TSL compute sort whenever the camera direction changes (falling back automatically on WebGLBackend).
  3. Hybrid PBR + native Raycaster picking: compose standard PBR actors (MeshStandardMaterial) and a ShadowMaterial shadow-catcher proxy disc alongside the splat cloud, and use THREE.Raycaster.intersectObject(splats) directly against the Gaussian ellipsoids for click/hover interaction.
  4. Drop-in .spz world loading (SPZLoader): swap the procedural geometry builder for SPZLoader (v1–v4) to load real compressed .spz radiance-field captures in two lines.

Implementation

Save webgpuGaussianSplat.ts in Assets/Game/:

import * as THREE from 'three';
import { GaussianSplat } from 'three/addons/objects/GaussianSplat.js';
import { SPZLoader } from 'three/addons/loaders/SPZLoader.js';
import {
  createGaussianSplatGeometry,
  createPackedSphericalHarmonicsBand,
  writeColorBytes,
  writeCovariance,
} from 'three/addons/utils/GaussianSplatUtils.js';

export interface SplatBuilder {
  readonly capacity: number;
  readonly count: () => number;
  readonly add: (
    x: number,
    y: number,
    z: number,
    sx: number,
    sy: number,
    sz: number,
    q: THREE.Quaternion,
    r: number,
    g: number,
    b: number,
    a: number,
    shTint?: number
  ) => void;
  readonly buildGeometry: () => THREE.BufferGeometry;
}

export interface WebGpuSplatSanctuary {
  readonly splats: GaussianSplat;
  readonly splatCount: number;
  readonly shadowCatcher: THREE.Mesh;
  readonly raycastFromCamera: (camera: THREE.Camera, ndcX?: number, ndcY?: number) => THREE.Vector3 | null;
}

function mulberry32(seed: number): () => number {
  let a = seed >>> 0;
  return () => {
    a |= 0;
    a = (a + 0x6d2b79f5) | 0;
    let t = Math.imul(a ^ (a >>> 15), 1 | a);
    t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
    return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
  };
}

function srgbToLinear(c: number): number {
  const x = Math.max(0, Math.min(1, c));
  return x <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
}

/**
 * Allocates flat typed arrays and packs positions, 6-float symmetric 3D covariances,
 * RGBA8 linear colors, and SH1 view-dependent spherical harmonics for Three.js r187's native GaussianSplat.
 */
export function createSplatBuilder(capacity: number): SplatBuilder {
  const centers = new Float32Array(capacity * 3);
  const covariances = new Float32Array(capacity * 6);
  const colors = new Uint8ClampedArray(capacity * 4);
  const sh1 = createPackedSphericalHarmonicsBand(capacity, 1);
  let cursor = 0;

  const add = (
    x: number,
    y: number,
    z: number,
    sx: number,
    sy: number,
    sz: number,
    q: THREE.Quaternion,
    r: number,
    g: number,
    b: number,
    a: number,
    shTint = 0.0
  ): void => {
    if (cursor >= capacity) return;
    const i = cursor++;
    centers[i * 3] = x;
    centers[i * 3 + 1] = y;
    centers[i * 3 + 2] = z;
    writeCovariance(covariances, i * 6, sx, sy, sz, q.x, q.y, q.z, q.w);
    // GaussianSplat unpacks RGBA8 directly into linear working space before ACES + sRGB output
    writeColorBytes(colors, i * 4, srgbToLinear(r) * 255, srgbToLinear(g) * 255, srgbToLinear(b) * 255, a * 255);

    // Pack subtle SH1 directional sheen (clamped byte: 128 + coeff * 128) for view-dependent sunlit gloss
    if (shTint !== 0) {
      const base = i * 12;
      const warm = Math.max(-0.45, Math.min(0.45, shTint));
      const cool = -warm * 0.55;
      // Y lobe (sky/top bounce)
      sh1.bytes[base + 0] = 128 + warm * 68;
      sh1.bytes[base + 1] = 128 + warm * 54;
      sh1.bytes[base + 2] = 128 + warm * 46;
      // Z lobe (key-light rim)
      sh1.bytes[base + 3] = 128 + warm * 48;
      sh1.bytes[base + 4] = 128 + warm * 34;
      sh1.bytes[base + 5] = 128 + cool * 32;
      // X lobe (cross-light contrast)
      sh1.bytes[base + 6] = 128 + warm * 52;
      sh1.bytes[base + 7] = 128 + warm * 38;
      sh1.bytes[base + 8] = 128 + cool * 36;
    }
  };

  const buildGeometry = (): THREE.BufferGeometry => {
    const used = cursor;
    const cSlice = centers.subarray(0, used * 3);
    const covSlice = covariances.subarray(0, used * 6);
    const colSlice = colors.subarray(0, used * 4);
    const sh1Slice = sh1.packed.subarray(0, used * 3);
    return createGaussianSplatGeometry(cSlice, covSlice, colSlice, { sh1: sh1Slice });
  };

  return { capacity, count: () => cursor, add, buildGeometry };
}

/**
 * Generates a deterministic 22,000-splat Sakura Bonsai & Koi Sanctuary geometry
 * (mossy basalt island, koi pond, gnarled bonsai trunk, layered cherry-blossom canopy,
 * glowing stone lantern, and drifting petals) compatible with native `GaussianSplat`.
 */
export function buildSanctuarySplatGeometry(seed = 202609): THREE.BufferGeometry {
  const rand = mulberry32(seed);
  const builder = createSplatBuilder(22500);
  const q = new THREE.Quaternion();
  const euler = new THREE.Euler();
  const up = new THREE.Vector3(0, 1, 0);
  const dir = new THREE.Vector3();

  // 1. Terraced mossy island & sculpted dark basalt rim (~5,800 splats)
  for (let i = 0; i < 4000; i++) {
    const ang = rand() * Math.PI * 2;
    const rad = Math.sqrt(rand()) * 3.85;
    const x = Math.cos(ang) * rad;
    const z = Math.sin(ang) * rad;
    const pondDist = Math.hypot(x - 1.15, z + 0.95);
    if (pondDist < 1.38) continue;

    const mound = Math.max(0, 1.0 - (rad / 3.9) * (rad / 3.9));
    const bump = Math.sin(x * 1.4) * Math.cos(z * 1.3) * 0.14;
    const y = 0.08 + mound * 0.56 + bump;

    euler.set((rand() - 0.5) * 0.25, rand() * Math.PI * 2, (rand() - 0.5) * 0.25);
    q.setFromEuler(euler);
    const edge = Math.max(0, (rad - 2.95) / 0.9);
    const s = 0.075 + rand() * 0.065;
    if (edge > 0.32) {
      // Sculpted dark basalt cliff stones around island edge
      const gVal = 0.19 + rand() * 0.11;
      builder.add(x, y - edge * 0.34, z, s * 1.25, s * 0.65, s * 1.1, q, gVal, gVal * 1.02, gVal * 1.08, 0.92, 0.08);
    } else {
      // Lush emerald-olive moss carpet with sunlit tips
      const g = 0.36 + mound * 0.20 + rand() * 0.12;
      builder.add(x, y, z, s * 1.3, s * 0.38, s * 1.25, q, g * 0.52, g, g * 0.36, 0.90, 0.16);
    }
  }

  // Sculpted basalt rock ring along the pond shore & underside shelf
  for (let i = 0; i < 1800; i++) {
    const ang = rand() * Math.PI * 2;
    const onPond = i < 700;
    const rad = onPond ? 1.32 + (rand() - 0.5) * 0.34 : 3.55 + (rand() - 0.5) * 0.45;
    const cx = onPond ? 1.15 + Math.cos(ang) * rad : Math.cos(ang) * rad;
    const cz = onPond ? -0.95 + Math.sin(ang) * rad : Math.sin(ang) * rad;
    const cy = onPond ? 0.24 + rand() * 0.22 : -0.18 + rand() * 0.38;
    euler.set(rand() * 0.8, rand() * Math.PI * 2, rand() * 0.8);
    q.setFromEuler(euler);
    const s = 0.08 + rand() * 0.085;
    const shade = 0.22 + rand() * 0.14;
    builder.add(cx, cy, cz, s * 1.35, s * 0.72, s * 1.15, q, shade, shade * 1.02, shade * 1.06, 0.94, 0.10);
  }

  // 2. Translucent turquoise koi pond + lily pads + koi fish (~1,600 splats)
  for (let i = 0; i < 1300; i++) {
    const ang = rand() * Math.PI * 2;
    const rad = Math.sqrt(rand()) * 1.34;
    const x = 1.15 + Math.cos(ang) * rad;
    const z = -0.95 + Math.sin(ang) * rad;
    euler.set(0, rand() * Math.PI * 2, 0);
    q.setFromEuler(euler);
    const depth = 1.0 - rad / 1.38;
    builder.add(
      x,
      0.16 + (rand() - 0.5) * 0.02,
      z,
      0.09 + rand() * 0.05,
      0.015,
      0.09 + rand() * 0.05,
      q,
      0.10 + (1 - depth) * 0.14,
      0.44 + (1 - depth) * 0.16,
      0.56 + depth * 0.12,
      0.78,
      0.34
    );
  }
  // Lily pads & 3 vibrant koi fish swimming in arcs
  for (let i = 0; i < 180; i++) {
    const padIdx = i % 9;
    const pa = padIdx * 0.72 + 0.4;
    const pr = 0.45 + (padIdx % 3) * 0.28;
    const x = 1.15 + Math.cos(pa) * pr + (rand() - 0.5) * 0.16;
    const z = -0.95 + Math.sin(pa) * pr + (rand() - 0.5) * 0.16;
    euler.set(0, rand() * Math.PI, 0);
    q.setFromEuler(euler);
    const isLotus = i % 15 === 0;
    if (isLotus) {
      builder.add(x, 0.23, z, 0.055, 0.04, 0.055, q, 0.98, 0.72, 0.82, 0.94, 0.28);
    } else {
      builder.add(x, 0.19, z, 0.085, 0.014, 0.085, q, 0.18, 0.52, 0.24, 0.92, 0.18);
    }
  }
  for (let k = 0; k < 3; k++) {
    const baseAng = k * 2.1 + 0.3;
    for (let seg = 0; seg < 24; seg++) {
      const t = seg / 23;
      const a = baseAng + t * 0.48;
      const r = 0.58 + k * 0.22;
      const x = 1.15 + Math.cos(a) * r;
      const z = -0.95 + Math.sin(a) * r;
      euler.set(0, -a, 0);
      q.setFromEuler(euler);
      const body = Math.sin(t * Math.PI) * 0.055 + 0.015;
      const whitePatch = seg > 8 && seg < 14 && k === 1;
      builder.add(x, 0.18, z, body, 0.022, body * 1.4, q, whitePatch ? 0.96 : 0.98, whitePatch ? 0.94 : 0.36, whitePatch ? 0.90 : 0.10, 0.96, 0.30);
    }
  }

  // 3. Sculpted ancient gnarled bonsai trunk, roots & 4 sweeping boughs (~4,200 splats)
  const addTube = (
    p0: [number, number, number],
    p1: [number, number, number],
    p2: [number, number, number],
    rStart: number,
    rEnd: number,
    splatsN: number
  ): void => {
    const aVec = new THREE.Vector3(...p0);
    const bVec = new THREE.Vector3(...p1);
    const cVec = new THREE.Vector3(...p2);
    const pos = new THREE.Vector3();
    const tan = new THREE.Vector3();
    for (let i = 0; i < splatsN; i++) {
      const t = rand();
      const inv = 1 - t;
      pos.set(
        inv * inv * aVec.x + 2 * inv * t * bVec.x + t * t * cVec.x,
        inv * inv * aVec.y + 2 * inv * t * bVec.y + t * t * cVec.y,
        inv * inv * aVec.z + 2 * inv * t * bVec.z + t * t * cVec.z
      );
      tan.set(
        2 * inv * (bVec.x - aVec.x) + 2 * t * (cVec.x - bVec.x),
        2 * inv * (bVec.y - aVec.y) + 2 * t * (cVec.y - bVec.y),
        2 * inv * (bVec.z - aVec.z) + 2 * t * (cVec.z - bVec.z)
      ).normalize();
      const radius = rStart + (rEnd - rStart) * t;
      const theta = rand() * Math.PI * 2;
      const shell = radius * (0.68 + rand() * 0.38);
      const ox = Math.cos(theta) * shell;
      const oz = Math.sin(theta) * shell;
      dir.copy(tan).addScaledVector(up, 0.2).normalize();
      q.setFromUnitVectors(up, dir);
      const bark = 0.24 + rand() * 0.13;
      const mossHint = t < 0.28 && rand() > 0.65;
      builder.add(
        pos.x + ox,
        pos.y + (rand() - 0.5) * radius * 0.35,
        pos.z + oz,
        radius * 0.36 + 0.025,
        radius * 0.72 + 0.04,
        radius * 0.36 + 0.025,
        q,
        mossHint ? 0.24 : bark * 1.18,
        mossHint ? 0.38 : bark * 0.88,
        mossHint ? 0.18 : bark * 0.68,
        0.95,
        0.12
      );
    }
  };

  // Main S-curved bonsai trunk
  addTube([-0.55, 0.55, 0.25], [-1.05, 1.85, 0.45], [-0.15, 3.05, 0.05], 0.46, 0.20, 1750);
  // Sweeping boughs carrying layered cherry-blossom clouds
  addTube([-0.68, 1.95, 0.32], [-1.75, 2.38, 0.40], [-2.25, 2.55, -0.15], 0.22, 0.09, 680);
  addTube([-0.38, 2.45, 0.18], [0.62, 2.65, -0.35], [1.45, 2.42, -0.78], 0.20, 0.08, 680);
  addTube([-0.30, 2.75, 0.12], [-0.10, 3.35, 0.75], [0.25, 3.62, 0.92], 0.18, 0.08, 580);
  addTube([-0.58, 0.65, 0.25], [-1.35, 0.55, -0.35], [-1.85, 0.42, -0.65], 0.22, 0.07, 450);

  // 4. Layered Sakura Cherry-Blossom Canopy Clouds with SH1 sunlit glow (~8,600 splats)
  const blossomClusters: [number, number, number, number, number, number][] = [
    [-0.15, 3.55, 0.15, 1.55, 0.68, 1.38], // Crown cloud
    [-2.15, 2.78, -0.12, 1.25, 0.54, 1.12], // Left sweeping bough
    [1.38, 2.68, -0.75, 1.28, 0.52, 1.18], // Right pond-overhanging bough
    [0.32, 3.85, 0.92, 1.15, 0.50, 1.05], // Rear high cloud
    [-1.12, 3.18, 0.68, 1.02, 0.46, 0.96], // Upper-left bridge cloud
    [0.65, 3.12, 0.22, 0.95, 0.44, 0.92], // Inner heart canopy
  ];
  const perCluster = Math.floor(8600 / blossomClusters.length);
  for (const [cx, cy, cz, rx, ry, rz] of blossomClusters) {
    for (let i = 0; i < perCluster; i++) {
      // Rejection-free spherical distribution concentrated gently near cluster silhouette
      const u = rand();
      const v = rand();
      const theta = u * Math.PI * 2;
      const phi = Math.acos(2 * v - 1);
      const rDist = Math.pow(rand(), 0.42);
      const dx = Math.sin(phi) * Math.cos(theta) * rx * rDist;
      const dy = Math.cos(phi) * ry * rDist;
      const dz = Math.sin(phi) * Math.sin(theta) * rz * rDist;

      euler.set(rand() * Math.PI, rand() * Math.PI, rand() * Math.PI);
      q.setFromEuler(euler);

      const sunFacing = Math.max(0, Math.min(1, 0.45 + (dy / ry) * 0.48 + (dx / rx) * 0.24));
      const blossomScale = 0.056 + rand() * 0.052;
      // Dimensional sakura gradient: velvety deep crimson-rose shadow -> vivid cherry blossom -> sunlit ivory blush
      const rCol = 0.62 + sunFacing * 0.37;
      const gCol = 0.14 + Math.pow(sunFacing, 1.3) * 0.62 + rand() * 0.06;
      const bCol = 0.32 + sunFacing * 0.54 + rand() * 0.05;
      builder.add(
        cx + dx,
        cy + dy,
        cz + dz,
        blossomScale * 1.32,
        blossomScale * 0.52,
        blossomScale * 1.12,
        q,
        Math.min(1, rCol),
        Math.min(1, gCol),
        Math.min(1, bCol),
        0.88 + rand() * 0.10,
        0.22 + sunFacing * 0.18
      );
    }
  }

  // 5. Carved Japanese stone lantern (Toro) with open firebox + warm amber light core (~1,300 splats)
  const lx = -1.85;
  const lz = -1.25;
  for (let i = 0; i < 900; i++) {
    const part = rand();
    let px = lx;
    let py = 0.55;
    let pz = lz;
    let sx = 0.068;
    let sy = 0.048;
    let sz = 0.068;
    if (part < 0.38) {
      // Pedestal & carved pillar
      const a = rand() * Math.PI * 2;
      const h = rand() * 0.92;
      const r = h < 0.18 ? 0.35 : 0.14;
      px += Math.cos(a) * r * Math.sqrt(rand());
      py = 0.42 + h;
      pz += Math.sin(a) * r * Math.sqrt(rand());
    } else if (part < 0.80) {
      // Pagoda capstone roof + finial jewel
      const a = rand() * Math.PI * 2;
      const r = Math.sqrt(rand()) * 0.52;
      px += Math.cos(a) * r;
      py = 1.66 + (0.52 - r) * 0.55;
      pz += Math.sin(a) * r;
      sx = 0.075;
      sy = 0.032;
      sz = 0.075;
    } else {
      // Four slender open firebox corner posts so the warm amber flame shines through
      const corner = Math.floor(rand() * 4) * (Math.PI * 0.5) + Math.PI * 0.25;
      px += Math.cos(corner) * 0.22;
      py = 1.32 + rand() * 0.34;
      pz += Math.sin(corner) * 0.22;
      sx = 0.038;
      sy = 0.055;
      sz = 0.038;
    }
    euler.set(0, rand() * Math.PI, 0);
    q.setFromEuler(euler);
    const stone = 0.30 + rand() * 0.14 + (py > 1.66 ? 0.08 : 0);
    builder.add(px, py, pz, sx, sy, sz, q, stone * 1.04, stone, stone * 0.95, 0.95, 0.10);
  }
  // Glowing golden-amber lantern flame core + subtle warm spill halo
  for (let i = 0; i < 400; i++) {
    const a = rand() * Math.PI * 2;
    const isHalo = i >= 260;
    const r = isHalo ? 0.14 + rand() * 0.24 : rand() * 0.13;
    euler.set(rand(), rand(), rand());
    q.setFromEuler(euler);
    builder.add(
      lx + Math.cos(a) * r,
      1.49 + (rand() - 0.5) * (isHalo ? 0.28 : 0.20),
      lz + Math.sin(a) * r,
      isHalo ? 0.085 : 0.055,
      isHalo ? 0.085 : 0.068,
      isHalo ? 0.085 : 0.055,
      q,
      1.0,
      isHalo ? 0.62 : 0.84 + rand() * 0.14,
      isHalo ? 0.16 : 0.28 + rand() * 0.16,
      isHalo ? 0.34 : 0.94,
      0.38
    );
  }

  // 6. Delicate drifting sakura petals & warm golden fireflies (~260 splats, clear of close lens)
  for (let i = 0; i < 260; i++) {
    const ang = rand() * Math.PI * 2;
    const rad = 1.45 + rand() * 2.55;
    const px = Math.cos(ang) * rad;
    const pz = Math.sin(ang) * rad;
    const y = 0.85 + rand() * 3.35;
    // Keep foreground camera sightlines clean
    if (Math.hypot(px - 2.9, pz + 4.4) < 2.2) continue;
    euler.set(rand() * Math.PI, rand() * Math.PI, rand() * Math.PI);
    q.setFromEuler(euler);
    const isFirefly = i % 4 === 0;
    if (isFirefly) {
      builder.add(px, y, pz, 0.028, 0.028, 0.028, q, 1.0, 0.86, 0.34, 0.90, 0.35);
    } else {
      builder.add(px, y, pz, 0.042, 0.014, 0.028, q, 0.99, 0.64, 0.80, 0.86, 0.22);
    }
  }

  return builder.buildGeometry();
}

/**
 * Instantiates Three.js r187's native `GaussianSplat` (backed by WebGPURenderer + TSL GPU
 * 4096-bin CountingSort + SH1 view-dependent spherical harmonics + built-in raycasting)
 * paired with a transparent PBR shadow-catcher disc for hybrid gameplay objects.
 */
export function createWebGpuSplatSanctuary(seed = 202609): WebGpuSplatSanctuary {
  const splatGeo = buildSanctuarySplatGeometry(seed);
  const splatCount = splatGeo.getAttribute('position').count;
  const splats = new GaussianSplat(splatGeo, { autoSort: true });
  splats.computeBoundingBox();
  splats.computeBoundingSphere();

  // Invisible shadow-receiving disc aligned with the mossy island terrace for hybrid PBR shadows
  const shadowCatcher = new THREE.Mesh(
    new THREE.CircleGeometry(3.6, 36),
    new THREE.ShadowMaterial({ opacity: 0.42 })
  );
  shadowCatcher.rotation.x = -Math.PI / 2;
  shadowCatcher.position.y = 0.56;
  shadowCatcher.receiveShadow = true;

  const raycaster = new THREE.Raycaster();
  const ndc = new THREE.Vector2();
  const raycastFromCamera = (camera: THREE.Camera, ndcX = 0, ndcY = 0): THREE.Vector3 | null => {
    ndc.set(ndcX, ndcY);
    raycaster.setFromCamera(ndc, camera);
    const hits = raycaster.intersectObject(splats, false);
    return hits.length > 0 ? hits[0].point.clone() : null;
  };

  return { splats, splatCount, shadowCatcher, raycastFromCamera };
}

/**
 * Drop-in loader for external `.spz` Gaussian splat captures (v1-v4, e.g. World Labs exports)
 * using Three.js r187's built-in `SPZLoader` and native `GaussianSplat`.
 */
export async function loadSpzSplatMesh(url: string): Promise<GaussianSplat> {
  const loader = new SPZLoader();
  const geometry = await loader.loadAsync(url);
  const splats = new GaussianSplat(geometry, { autoSort: true });
  splats.computeBoundingBox();
  splats.computeBoundingSphere();
  return splats;
}

Wiring in main.ts (and loading .spz files)

import { createWebGpuSplatSanctuary, loadSpzSplatMesh } from './webgpuGaussianSplat.js';

// Option A: procedural 21k-splat sanctuary with hybrid shadow catcher & raycast picking
const sanctuary = createWebGpuSplatSanctuary(202609);
scene.add(sanctuary.splats, sanctuary.shadowCatcher);

// Option B: load a compressed .spz capture stored in Assets/Game/Splats/scene.spz
// const spzSplats = await loadSpzSplatMesh(game.url('Assets/Game/Splats/scene.spz'));
// scene.add(spzSplats);

Tuning & Budget

  • Automatic WebGPURenderer activation: importing GaussianSplat, three/webgpu, or three/tsl (or setting "renderer": "webgpu" in game.json) switches the build to WebGPURenderer and bundles three.webgpu.js + three.tsl.js cleanly while standard WebGL 2 games keep zero WebGPU overhead.
  • SH degree budget: SH1 (3 uint32 words per splat) captures rich directional sunlit sheen at minimal bandwidth; reserve SH2/SH3 for hero captured .spz assets with glossy chrome/water reflections.
  • Hybrid shadow grounding: place a ShadowMaterial plane/disc matching the splat ground plane so opaque PBR characters and props cast grounded shadows onto the radiance field.

Common Pitfalls

  • Never mix legacy WebGLRenderer with GaussianSplat: GaussianSplat requires WebGPURenderer (whose built-in WebGLBackend provides WebGL 2 fallback when WebGPU is unavailable).
  • Avoid raw GLSL ShaderMaterial in WebGPU scenes: pair GaussianSplat with standard Three.js materials (MeshStandardMaterial, MeshBasicMaterial, ShadowMaterial) or TSL NodeMaterials so every pass compiles on both WebGPU and WebGLBackend.
  • Call computeBoundingBox() / computeBoundingSphere() on GaussianSplat so frustum culling and Raycaster.intersectObject(splats) stay tight and fast.

Official references

  • Bernhard Kerbl, Georgios Kopanas, Thomas Leimkühler & George Drettakis (SIGGRAPH 2023 — 3D Gaussian Splatting for Real-Time Radiance Field Rendering)
  • SIGGRAPH 2026 / HPG 2026 — High-Throughput GPU Splat Sorting & KHR_gaussian_splatting
  • Three.js r187 WebGPURenderer, GaussianSplat & SPZLoader Reference

More Three.js games

Games made with GameCrew on the same engine. No game has been built with this guide yet: these show what Three.js games here look like.

More Three.js techniques

physics

BVH Mesh & Character Capsule Collision in Three.js →

Fast capsule-vs-triangle pushout and slope resolution using three-mesh-bvh shapecasts, pre-allocated scratch vectors, and CollisionWorld.

rendering

Hybrid 3D Gaussian Splatting (3DGS) Diorama & Proxy-Mesh Shadow Compositing in Three.js (WebGL 2) →

Render anisotropic 3D Gaussian Splat backdrops and dioramas in Three.js r183 WebGL 2 via instanced quads, EWA perspective covariance projection, and zero-allocation bucket depth sorting, composited cleanly with opaque PBR gameplay actors and a ShadowMaterial shadow-catcher proxy floor.

rendering

Momentum-Conserving Stochastic Particle Terrain Erosion in Three.js →

Carve realistic dendritic valleys, sharp ridges, alluvial sediment fans, and stream-flow splat masks on a 128x128 heightfield in under 35 ms in Three.js r183 using momentum-conserving stochastic water droplets and thermal talus relaxation.

optimization

Instanced Wind Foliage, Object-Pooled Particles & Spring Feel in Three.js →

Single-draw-call THREE.InstancedMesh wind foliage with player bend, zero-GC pooled burst particles, and dt-invariant second-order springs that keep 60 Hz steps under 2 ms.

Read via free MCP — or sign in to add techniques & beta test

Use /mcp/library free with no login to query guides, or connect via OAuth at /mcp to contribute technique guides and beta test cloud builds.

Connect via MCP