Quick start
You need three.js r187 or newer with WebGPURenderer, and a browser with WebGPU.
pnpm add @pmndrs/reflections three
pnpm add denoiser # optional: steady glossy reflectionsThe whole hybrid, in one object
Reflections wires the G-buffer, screen-space reflections, a baked probe for what the screen cannot see, an optional
ray-traced fallback and an optional denoiser into a RenderPipeline. You call reflections.render(camera) where you
called renderer.render(scene, camera).
import * as THREE from 'three/webgpu';
import { Reflections, createReflectionsRenderer } from '@pmndrs/reflections/three';
import { FfxReflectionDenoiser } from 'denoiser/ffx'; // optional, see below
// A WebGPURenderer with the device limits the passes need (it is initialised for you).
const renderer = await createReflectionsRenderer({ canvas });
// Your scene: standard or physical materials, an environment, a glossy floor.
const scene = new THREE.Scene();
scene.environment = environmentTexture;
// ...
const reflections = await Reflections.create(renderer, scene, {
denoiser: (device, { roughnessThreshold }) =>
new FfxReflectionDenoiser(device, { roughnessThreshold: roughnessThreshold ** 2 }),
});
renderer.setAnimationLoop(() => reflections.render(camera)); // instead of renderer.render(scene, camera)
Tone mapping and the output colour space are the renderer's: set renderer.toneMapping as usual.
A complete page with a scene is examples/quickstart.
What Reflections.create takes
Without a denoiser, glossy reflections are one noisy sample per 2x2 pixel quad. Use one.
Every piece is public on the object (reflections.ssr, .hybrid, .probes, .pipeline) for anything the options do
not cover. After the scene or its environment changes, call reflections.bake() to re-capture the probe.
Probes only
The cheapest path for an existing project: no extra passes. One baked probe, and every physical material reflects it (box-projected, prefiltered by roughness). It shows the scene as it was when baked and does not follow moving objects.
import { ReflectionProbe, ReflectionProbes, installCubeArraySupport, reflectionProbes } from '@pmndrs/reflections/three';
await installCubeArraySupport(renderer); // r187 cannot bind cube arrays yet; this adds it
const probes = new ReflectionProbes();
const room = new ReflectionProbe(12, 6, 12); // influence box: width, height, depth
room.position.set(0, 2.5, 0); // the capture point
probes.add(room);
scene.add(probes);
probes.bake(renderer, scene);
scene.environmentNode = reflectionProbes(probes);
renderer.render(scene, camera) stays as it is. See examples/quickstart/probes.html.
Which materials get reflections
MeshStandardMaterial and MeshPhysicalMaterial, and their node versions. Basic, Lambert and Phong materials have no
physically based specular term to replace, so they are left as three draws them.
The denoiser
denoiser/ffx is a separate package (denoiser, version 2 or newer): a
reflection denoiser written in WGSL, running on the renderer's device. It is what makes glossy reflections steady at
rest and in motion. If you leave the option out, reflections still work and glossy surfaces are just noisier.
Next
- Using React Three Fiber? See the React Three Fiber guide. Babylon.js or pixi.js? See the adapter comparison.
- Want to see it run? The examples page lists every live example, and the gallery opens them.
- To tune: every setting, its default and its cost is in the settings guide.