Skip to content
pmndrsPublic

About

Global illumination for the Modern Web.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

1,737 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@pmndrs/gi

npm examples license

Real-time global illumination for WebGPU. Light bounces around your scene and keeps up as lights, objects and the sun move. An engine-free GI platform carries the techniques; the first is Dynamic Diffuse Global Illumination (DDGI): a grid of probes that trace rays every frame. Plain WebGPU and WGSL underneath, with a three.js adapter on top.

▶ Examples: small pages, each showing one feature, running in your browser. They need a browser with WebGPU (see Browser support).

Cornell box lit by DDGI: the red and green walls bleed colour onto the floor, ceiling and boxes

Status: a working prototype, not published yet. Light bounces in real time through a grid of probes, and follows moving lights, objects and the sun, textured materials, several probe volumes and one that follows the camera. Quality presets for slower GPUs, saved bakes and an export to three's LightProbeGrid are in. What's in the first release, and what isn't checked yet, is in CHANGELOG.md.

Install

npm install @pmndrs/gi three

One package, an import path per layer:

Import For Needs
@pmndrs/gi/three (or @pmndrs/gi) three.js WebGPURenderer, with DDGI's DDGIVolume and ddgi() composite three r187 (~0.187.0)
@pmndrs/gi/core The GI platform on your own GPUDevice: the scene, rays, light and sky that techniques build on, for plain WebGPU or an adapter for another engine nothing: three isn't needed
@pmndrs/gi/ddgi The DDGI technique, engine-free, run on the platform from /core nothing: three isn't needed
@pmndrs/gi/radiance-cache The radiance cache (based on AMD GI-1.0/1.2: screen probes over a world cache), engine-free, run on the platform from /core; with three.js its screen inputs, GI light and composite come from /three nothing: three isn't needed (its denoiser, denoiser, installs with the package)
@pmndrs/gi/radiance-cascades Split radiance cascades on your own GPUDevice (the experiment below) nothing: three isn't needed

three is an optional peer dependency, so a project that only imports /core and /ddgi doesn't install it. With TypeScript, add @webgpu/types for the WebGPU types.

Bundlers

The ray-tracing trees come from @pmndrs/bvh, which installs with the package and builds meshes' trees in web workers it starts from its own files. Vite and webpack 5 ship those files in a production build with no setup. Vite's dev server needs @pmndrs/bvh kept out of its dependency pre-bundling, or the workers aren't found and the trees are built on the main thread instead (it works, but slower):

// vite.config.js
export default { optimizeDeps: { exclude: ['@pmndrs/bvh'] } };

esbuild ships no worker files at all; see @pmndrs/bvh's docs ("Workers", "Bundlers and dev servers").

Getting started with three.js

GI takes the place of three's LightProbeGrid, in as many lines. You give it a box and a number of probes; start copies your scene, warms the probes up, and from then on GI updates itself inside renderer.render:

import * as THREE from 'three/webgpu';
import { createGIRenderer, DDGIVolume } from '@pmndrs/gi/three';

const { renderer } = await createGIRenderer(); // a WebGPURenderer on a device with the limits GI needs
renderer.setSize(innerWidth, innerHeight);
document.body.appendChild(renderer.domElement);

const scene = new THREE.Scene(); // your meshes, materials and lights, as usual
const camera = new THREE.PerspectiveCamera(50, innerWidth / innerHeight, 0.1, 100);

const volume = new DDGIVolume(6, 5, 6, 6, 6, 6); // like new LightProbeGrid(6, 5, 6, 6, 6, 6): a 6 × 5 × 6 m box, 6 probes a side
volume.position.set(0, 2.5, 0);
scene.add(volume);
await volume.start(renderer, scene); // like probes.bake(renderer, scene)

renderer.setAnimationLoop(() => renderer.render(scene, camera)); // no per-frame GI call

What's different from LightProbeGrid:

  • It keeps updating. Move a light, open a door or turn the sun, and GI follows within a few frames. bake is a one-off.
  • It knows about walls. Each probe keeps how far it can see in every direction, so light leaks far less through walls between probes, and probes inside walls switch themselves off.
  • createGIRenderer makes three's renderer on a GPU device with the adapter's full limits. three's own device caps a storage buffer at WebGPU's default, 128 MiB, which large scenes (Sponza, Bistro) outgrow. If you make the renderer yourself, pass it requiredLimits(adapter) from @pmndrs/gi/core.
  • One word sets the quality for slower GPUs: await volume.start(renderer, scene, { preset: 'low' }).

Where to go next:

  • The examples (source): the code above on three's own probe-grid scene (01-hello), GI added once per pixel on three's post-processing pipeline (02-composite), and one small page for each feature.
  • docs/api/three.md: the three.js adapter, every option, and what it does with your scene.
  • docs/guides/adapter.md: GI from plain WebGPU, or an adapter for another engine, step by step through examples/webgpu/hello/.
  • docs/api/platform.md: the engine-free API, @pmndrs/gi/core and @pmndrs/gi/ddgi.
  • docs/api/radiance-cache.md: the second technique, the radiance cache (screen probes over a world cache, from AMD GI-1.0/1.2), with three.js or without; its example is cache/c1-no-volume. DDGI or the radiance cache says which to use, and how to stack DDGI under the cache.

The examples run from this repository: pnpm install, then pnpm examples. The viewer (pnpm dev) shows every test scene with GI, its debug views and its settings.

Split Radiance Cascades experiment

▶ Try it live: a lamp-lit gallery you can walk through. You can also watch a shutter close over a lamp.

Import SplitRcTechnique from @pmndrs/gi/radiance-cascades and add it to the GI platform as you would DDGI or the radiance cache; it is engine-free WebGPU and WGSL. It follows the paper's structure: sparse probes in four cascades, with levels of detail around the camera. Its WGSL passes own the probes and write each pixel's diffuse irradiance. The example compares it with the Three.js port on the same rail and offers temporal upscaling; locally it is at /cascades/11-radiance-cascades/ under pnpm examples. It has no reflections yet. Project spec · Implementation plan · Research

Browser support

GI runs on WebGPU only; there is no WebGL fallback.

  • Browsers with WebGPU: Chrome and Edge 113 and later; Safari 26 and later (macOS, iOS and iPadOS).
  • Checked on: the target devices, an RTX 3060 Laptop GPU (Windows, Chrome) and an Apple M5 Pro (macOS, Chrome), and the correctness device, an Intel UHD integrated GPU (Windows, Chrome). Safari, an iPad and an older iOS device haven't been run yet.
  • Slower GPUs: pick a lower preset ({ preset: 'low' }), or let recommendPreset (from @pmndrs/gi/ddgi) pick one from the adapter.
  • Large scenes need more GPU memory per buffer than WebGPU's defaults. createGIRenderer asks for the adapter's full limits; if you make the device yourself, pass it requiredLimits(adapter) from @pmndrs/gi/core.

Documentation

Credits

Built by Dennis Smolek, to be maintained under the Poimandres collective.

License

MIT, see LICENSE. The bundled tinybvh, Emscripten runtime and HIPRT code keep their own licences; the package's THIRD_PARTY.md lists them, with their texts in licenses/.

Working on this repository

Optional, once: node tools/linked-siblings.ts --fetch clones the sibling pmndrs/pathtracer next to this repository for the radiance cache's neural tail (@pathtracer/mlp, not on npm). Without it everything else works and the tail stays off (docs/HANDOFF-radiance-cache.md, "The GI denoiser and linked siblings").

pnpm install
pnpm dev             # the viewer: every test scene with GI, its debug views and settings
pnpm examples        # the examples site, at http://localhost:5203
pnpm lint && pnpm typecheck && pnpm test
pnpm build           # the package, into packages/gi/dist
pnpm verify:packed   # packs it and checks it as a user would get it
pnpm test:release    # runs the publish workflow's steps against throwaway repositories
pnpm test:gpu        # the GPU checks, in headless Chrome on a real GPU

The published package, @pmndrs/gi, is packages/gi; each of its subpaths re-exports private workspace packages, all bundled in: core (the engine-free platform, /core), ddgi (DDGI, /ddgi), cache (the radiance cache, /radiance-cache), radiance-cascades (Split RC, /radiance-cascades), three (the three.js layer every technique shares) and ddgi-three (DDGI's volume and LightProbeGrid export; with three, . and /three), plus bvh. Each folder under packages/ is one package, named @pmndrs/gi-<folder> (docs/DECISIONS.md, 2026-11-27 and 2026-11-28). docs/releasing.md says how a release is cut, and what CI checks and doesn't.

How the work is run:

  • SPEC.md: what v1 is, how it's built, how we judge it, and the milestones.
  • PLAN.md: build order, how agents work, and what "done" means for a task.
  • TASKS.md and PROGRESS.md: the live task board and the running log.
  • docs/milestones/: one note per milestone, with what works, its checks and its known misses.
  • CLAUDE.md: orientation for agents; docs/NOTES.md and docs/DECISIONS.md: learned facts and settled choices.
  • docs/AUDIT-2026-10-30.md: why this is a fresh start. It reviews the earlier experiment in DennisSmolek/ddgi.
  • research/: background notes carried over from that experiment.
  • native/rtxgi-ddgi: NVIDIA's RTXGI-DDGI test harness (a fork), used only as an external comparison and timing tool. Its code is not part of this library.

About

Global illumination for the Modern Web.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages