Examples

Every live example, what it shows and what to compare it against.
Note

This page is generated from examples/catalog.ts by pnpm docs:examples. Edit the catalog, not this file.

The example gallery has a card for every page below. Each page opens with a short brief: what it shows, what to try and what to switch off to see the plainer way. The examples need a browser with WebGPU.

Showcase

The whole pipeline on real models, and the tools to judge it against a path tracer.

Showcase

All the reflection sources on real models: a car concept, a toy car, a chess set on a mirror floor, and Sponza with a polished floor.

What it shows. The full package on real models: probes, screen-space reflections, the ray-traced fallback and the denoiser, combined per pixel, with the GPU time of each pass.

Compare. Press Off for the baseline, or untick a source's checkbox to see the image without it

Try this.

  • Press Off, then On: the difference is every reflection the package adds
  • Turn off Screen-space (SSR) and turn on the Ray-traced fallback, then the other way round
  • Set Debug view to the source map to see which source each pixel took

Open the live page · Source · Docs

Compare with a path tracer

Real-time reflections next to a path-traced reference of the same view, split by a draggable divider.

What it shows. How close the real-time reflections get to a path-traced reference of the same view, and where they differ.

Compare. The right side is the path tracer, the reference. Drag the divider to move between it and the left side.

Try this.

  • Freeze the camera, wait for the path tracer to converge, then drag the divider
  • Set the left side to three.js SSR and compare it with this package

Open the live page · Source · Docs

Getting started

The smallest complete programs: reflections on a three.js scene in a few lines.

Quick start

Reflections on an ordinary three.js scene: one Reflections.create() and reflections.render(camera).

What it shows. The smallest complete program: an existing three.js scene gets screen-space reflections, a probe for what the screen cannot see, and the denoiser, all from one object.

Compare. The reflections checkbox. Unticked, three.js draws the scene without this package.

Try this.

  • Untick the reflections checkbox: three.js draws the scene alone, with the probe as its environment
  • Add ?rt=1 to the URL for the ray-traced fallback, or ?preset=performance for half-resolution reflections

Open the live page · Source · Docs

Probes only

One baked reflection probe and your own renderer.render(): the cheapest way, with no extra passes.

What it shows. The cheapest reflections: one baked, box-projected probe that every material samples, with the render loop you already have.

Compare. The quick start page, which adds screen-space reflections and the denoiser on top of the probe

Try this.

  • Orbit the camera: the reflections in the floor stay where they belong (that is box projection)
  • Open the quick start in another tab: screen-space reflections add the sharp contact reflections a probe cannot hold

Open the live page · Source · Docs

React Three Fiber

The quick start in React Three Fiber v10, with a useReflections() hook.

What it shows. The same reflections in React Three Fiber: a plain scene and one hook.

Try this.

  • Orbit around the spinning knot: its reflection on the floor follows it (that is screen-space reflections)
  • Add ?rt=1 or ?preset=performance to the URL

Open the live page · Source · Docs

Features

One thing each, over a baseline you can switch back to.

Box-projected probe

One baked probe in a room, projected onto the walls, so reflections stay put as you move.

What it shows. Why a probe is box-projected. Without it, the windows and walls reflected in the glossy floor sit in the wrong place and slide as the camera moves.

Compare. Untick Box projection. The same probe is then looked up by direction only, so reflections behave as if infinitely far away.

Try this.

  • Untick Box projection and orbit: the window reflections slide across the floor
  • Switch the view to Floor and toggle Box projection again
  • Turn on the volumes: the projection box is the room's walls

Open the live page · Source · Docs

Two rooms

A probe in each room and one in the doorway, blended by their influence boxes: each room reflects itself.

What it shows. Why a level needs more than one probe: each room reflects its own walls and light, and the doorway probe blends one room into the other without a seam.

Compare. Untick One probe per room. One probe, captured in the warm room, is then projected onto the whole building.

Try this.

  • Untick One probe per room: the cool room's floor and the mirror ball now show the warm room
  • Turn on Show blend weights, then pick Across the doorway: the colours mix where the boxes overlap
  • Watch the mirror ball roll through the doorway: its reflection hands over from one room to the other

Open the live page · Source · Docs

Live probes

Probes captured again while the scene runs, one per frame: a turning knot and two colour-cycling lights in two rooms.

What it shows. Probes that follow the scene. One probe is captured again each frame as the lights change colour and the knot turns, so the reflections stay current.

Compare. Untick Live capture. The same probes are then baked once at load and never updated.

Try this.

  • Untick Live capture: the floor and the mirror ball keep the light colours from when the page loaded
  • Set Probes per frame to all 3: the same image at three times the capture cost

Open the live page · Source · Docs

Keep a mirror out of its own probe

bake({ exclude }) keeps a moving mirror out of the live probe it reflects, so it does not paint itself onto the room.

What it shows. Why moving mirrors are kept out of probes. Captured, the knot is painted onto the wall and the floor, and the mirror floor shows a second, smeared knot where there is none.

Compare. Untick Exclude the mirror knot. The knot is then captured into the probe and painted onto the room.

Try this.

  • Untick Exclude the mirror knot: a ghost knot slides across the floor's reflection of the wall
  • Untick Move, tick Show the probe and orbit: the ghost is the knot as seen from the capture point (the mirror sphere), painted onto the wall

Open the live page · Source · Docs

Screen-space reflections

Screen-space reflections on a polished floor, over a probe: the objects stand on their reflections.

What it shows. What screen-space reflections add over a probe: sharp reflections of everything on screen, including the objects a probe leaves out.

Compare. Untick Screen-space reflections. You then see the probe alone (three.js's lit image of the same frame).

Try this.

  • Untick Screen-space reflections: the sphere and the box lose their reflections, and the wall keeps its own
  • Raise Floor roughness: the reflection blurs with distance from the contact point, and the denoiser keeps it steady
  • Pick At the sphere: the floor reflects the sphere's underside, which the camera cannot see (the probe fills it in)

Open the live page · Source · Docs

What screen space misses

Off screen, behind the camera, hidden: what screen-space reflections cannot see, and the probes that fill it in.

What it shows. Where screen-space reflections run out: things off screen, behind the camera or hidden behind other objects. The probes fill those pixels so the image stays whole.

Compare. Untick Fill misses from the probes. You then see screen space alone, black wherever a ray found nothing on screen.

Try this.

  • Untick Fill misses from the probes: the ring in the floor and the whole wall mirror go black
  • Tick Tint the misses: magenta marks how much of each smooth pixel the probes filled
  • Pick Behind the camera: the mirror shows the bars behind you only through the probe

Open the live page · Source · Docs

Ray-traced fallback

Rays fill what screen space misses: reflections of things above the frame and behind the camera.

What it shows. What the ray-traced fallback adds over screen space plus probes: sharp reflections of things off screen, in the right place, including objects the probe never captured.

Compare. Untick Ray-traced fallback (reflections.ssr.rayTracing = false). The misses then take the probe instead.

Try this.

  • Untick Ray-traced fallback and watch the wall mirror: the cylinder and the box vanish from it (the probe never saw them) and the bars go soft
  • Switch the view to Wall mirror and toggle the fallback again
  • Turn on the view that shows where each pixel's reflection comes from: blue is a traced ray, green is screen space, red is the probe

Open the live page · Source · Docs

Ray tracing moving meshes

reflections.trace.refit() each frame keeps the ray-traced reflections of moving meshes where the meshes are.

What it shows. Why moving meshes need trace.refit() each frame. Without it, rays still hit them where they stood at load, so their reflections lag or ghost.

Compare. Untick Refit. The BVH then keeps the pose it was built with, and the reflections go stale.

Try this.

  • Untick Refit: the traced part of the knot's and the ball's reflections stays where they started
  • Turn on Show traced pixels: those are the pixels a stale BVH gets wrong
  • Untick Animate to hold a pose and compare

Open the live page · Source · Docs

The hybrid, explained

Probe, screen space, rays and the hybrid in one room: where each is right, where each breaks, and which source each pixel took.

What it shows. How the hybrid picks a source for each pixel: screen space where a ray hits, rays where it misses, the blurred probe for rough surfaces. It also shows why each source alone falls short.

Compare. Each source alone: probe only, screen space + probe, or rays for every pixel. Use the switch under the image, or "Reflections from".

Try this.

  • Step through the situations and switch between the two methods under the image
  • Turn on "where reflections come from" and tilt the view down at the floor
  • In "Rough surfaces", drag the roughness cutoff to 1

Open the live page · Source · Docs

Denoising glossy reflections

The denoiser on glossy surfaces, with a live flicker meter.

What it shows. What the denoiser does for glossy reflections. The tracer's one noisy sample per 2x2 block becomes a steady image, and the meter shows how steady.

Compare. Tick Denoiser off. You then see the raw signal: one ray per 2x2 block of pixels per frame.

Try this.

  • Tick Denoiser off and watch the middle of the ramp (roughness 0.2 to 0.4) and the meter
  • Switch the view to Floor strips: the chrome strips go from mirror to rough
  • Orbit, let go, and watch the meter settle

Open the live page · Source · Docs

Materials

How roughness, metalness and clear coat change reflections, and why basic, Lambert and Phong materials get none.

What it shows. Which materials get reflections, and how roughness, metalness and clear coat shape them. Basic, Lambert and Phong get none.

Compare. Tick Classic materials. The spheres switch to Phong, Lambert or Basic, while the floor strips stay standard.

Try this.

  • Tick Classic materials: the spheres turn Phong and lose their reflections (the highlight is from the lights, not a reflection)
  • Set the Blue row to Physical, clear coat: a sharp coat over a rough base
  • Switch the view to Floor strips: chrome goes from mirror to rough

Open the live page · Source · Docs

Animation and camera cuts

A camera path, moving objects and a camera cut with resetHistory().

What it shows. A whole animated scene, with a camera path and moving objects, staying steady through the moves. resetHistory() runs at the camera cuts and only there.

Compare. Tick Reset history on camera moves. The denoiser then never gets past its first frame, and the glossy floor shows the tracer's raw noise while the camera moves. (Leaving out the reset at a cut barely shows, because the denoiser rejects history whose depth and normals disagree. A cut still needs it.)

Try this.

  • Watch the floor through the camera moves and the cuts: it stays steady, with no shimmer
  • Tick Reset history on camera moves: the floor sparkles until the shot ends
  • Pause: the image holds still

Open the live page · Source · Docs

Presets

The default and performance presets (half-resolution reflections), with GPU time per pass.

What it shows. What the performance preset saves (the reflection passes run on a quarter of the pixels) and what it costs: softer reflections and jagged edges in mirrors.

Compare. Toggle Performance preset: it switches between the performance preset (half-resolution reflections) and default.

Try this.

  • Tick Performance preset and read the GPU times in the panel
  • Set the view to Mirror ball and toggle again: the ball's reflected edges are where half resolution shows
  • Orbit near the floor: the rough floor barely changes

Open the live page · Source · Docs

Upscaling

Temporal anti-aliasing and upscaling after the composite, with @pmndrs/upscaler and its jitter wired through.

What it shows. Rendering the scene and its reflections below the display size, then upscaling after the composite. Every reflection pass handles fewer pixels, and you get anti-aliasing with it.

Compare. Tick Upscaler off. Every pass then runs at the display resolution, with no anti-aliasing.

Try this.

  • Tick Upscaler off: the image is at display resolution with no anti-aliasing (edges and the last shimmer return)
  • Set Upscale to Performance (2x), orbit, then let go: this is a quarter of the pixels
  • Set Upscale to Native AA: the upscaler works as temporal anti-aliasing only

Open the live page · Source · Docs

Probes in your own TSL material

sampleReflectionProbes in a custom TSL material, here a water surface.

What it shows. Sampling the reflection probes from your own TSL material: a rippled water surface that reflects the room through sampleReflectionProbes().

Compare. Tick Stock material. A glossy, flat MeshStandardMaterial then reflects the same probe.

Try this.

  • Tick Stock material: a glossy MeshStandardMaterial replaces the water, using the same probe through three.js's lighting, flat
  • Untick Ripples: the custom material becomes a fresnel mirror
  • Orbit low over the pool: the fresnel brings the windows up at grazing angles

Open the live page · Source · Docs

Device limits

What a plain new WebGPURenderer() costs: a second lit pass, and traceError when ray tracing does not fit.

What it shows. What changes on a renderer with WebGPU's default limits: a second scene draw for the lit image, estimated specular weights, and ray tracing turning itself off (with traceError) when it does not fit. Nothing fails.

Compare. Set Renderer to createReflectionsRenderer() (the page reloads). The image barely changes. What differs is the extra scene draw and the estimated specular weights, which the panel shows.

Try this.

  • Read the panel, then set Renderer to createReflectionsRenderer(): one scene draw, with specular taken from the material
  • On the plain renderer, set Ray tracing to the 9-buffer scene copy: the status line shows pass.traceError

Open the live page · Source · Docs

Engines

One page per adapter, each with the features that adapter has.

three.js

three.js WebGPURenderer with every feature, on the two rooms that all the engine pages share.

What it shows. The three.js adapter with everything on: probes per room, screen-space reflections, the denoiser and, on a switch, the ray-traced fallback. The other engine pages draw this scene from the same views.

Compare. Turn Screen space off (probes only); every engine page has this switch. Or open another engine page at the same View.

Try this.

  • Turn Screen space off: the floor keeps the probes' blurrier, box-projected reflections
  • Turn the Ray-traced fallback on, set View to ball, and watch what the screen cannot see
  • Open the Babylon.js or Raw WebGPU page at the same View and compare

Open the live page · Source · Docs

React Three Fiber

The two rooms as JSX, with every feature of the three.js page through the useReflections hook.

What it shows. Everything the three.js page has, in React: the rooms and their probes as JSX, and reflections from one hook.

Compare. Turn Screen space off (probes only). Or open the three.js page, which should look the same.

Try this.

  • Turn Screen space off: probes only
  • Turn the Ray-traced fallback on (the hook's component remounts with a BVH)
  • Open the three.js page next to it at the same View

Open the live page · Source · Docs

Babylon.js

The two rooms built in Babylon.js: probes and screen-space reflections as frame-graph tasks.

What it shows. The engine-agnostic core on Babylon.js: the same probes and tracer as engines/three, wired into Babylon's frame graph, on the same two rooms.

Compare. Screen space off (probes only); and engines/three at the same View

Try this.

  • Turn Screen space off: probes only, as on the three page
  • Set Debug to radiance or confidence: what the tracer hands the composite
  • Open engines/three at the same View: the difference is lighting, shadows and the missing denoiser

Open the live page · Source · Docs

Raw WebGPU

The probe set and the screen-space tracer on a bare GPUDevice, with no engine, on the two rooms.

What it shows. The core API with no engine, which is what every adapter wraps. A minimal renderer fills the frame contract, and the core's probes, tracer and denoiser do the rest.

Compare. Turn Screen space off (probes only). Or open the three.js page at the same View.

Try this.

  • Turn Screen space off: probes only
  • Set Show to lit, then reflection: the scene colour the tracer reads, and what the composite adds
  • Open the three.js page at the same View

Open the live page · Source · Docs

Lab

Developer pages: the checks and benches the repository runs on a real GPU. To read and poke at, not demos.

Not on the site

pixi.js + pixi-3d, Radiance cache study: in the repository and the local gallery, left out of the public site (needs the closed pixi-3d beta; needs a local pathtracer checkout).