A real-time renderer has three ways to answer "what does this shiny pixel reflect?", and engines mix them. This page puts all
of them in one room so you can see where each one is right and where it breaks, on this package's own pipeline:
Reflections with a baked probe, the screen-space tracer, the ray-traced fallback and the denoiser. Step through the
situations below: each one sets up the camera and names the two methods worth comparing. Switch between them under the
image; drag the view to look around.
Pick a situation
Reflections from
Reflection denoiser
Hybrid roughness cutoff
rougher than this: probe only, no raysFloor gloss
roughness of the floor and the table topCamera
Sculpture
For each pixel, the renderer knows the surface: where it is, which way it faces, how rough it is. A mirror reflects one exact direction. A rough surface reflects a spread of directions around it (the "lobe"), which is why rough reflections are blurry. So the question is always: what light comes from those directions?
The noisy methods here answer it the way a path tracer would: pick one random direction in the lobe per pixel per frame,
find what is there, and let a denoiser (FFX's reflection denoiser, from denoiser/ffx) average neighbouring pixels and
previous frames into a clean image. Switch the denoiser to "raw" to see that one sample. Every mode below uses the same
random directions; they differ only in how they find what is in that direction.
Photograph the room once, in all six directions, from one point (a cubemap). Pre-blur copies of it for each roughness. At draw
time, look up the reflected direction. Box projection first works out where that ray would hit the room's walls, so walls
line up. Here: ReflectionProbes, baked once, every material sampling it through reflectionProbes(probes).
The frame being rendered already has the colour and depth of every visible surface. Walk along the reflected ray in screen space and stop where it passes behind a surface in the depth buffer: that pixel's colour is the reflection. This package's tracer is a port of AMD's FidelityFX SSSR: it steps through a depth pyramid, so long rays take few steps.
Shoot a real ray into the scene's triangles. A BVH (a tree of boxes around the geometry, built by @pmndrs/bvh
and walked by @pmndrs/raytracer) lets it skip everything the ray can't hit. At the hit, shade the surface cheaply: its
colour, roughness and metalness from a per-triangle table, lit by the probe at the hit.
reflections.trace.refit()). Shading at the hit is simplified (no textures, no second bounce).
Use each method where it's good. Rougher than a cutoff: the prefiltered probe, no ray. Glossy: try screen space first (cheap,
exact on screen). Where it finds nothing, trace a real ray. Where that ray leaves the room, use the probe. This is AMD's
FidelityFX "hybrid reflections" recipe, and roughly what Unreal's and Unity's high-end pipelines do. It is what
Reflections.create(renderer, scene, { rayTracing: true }) runs.
| probe | screen space + probe | ray traced | hybrid | |
|---|---|---|---|---|
| Reflects things off screen | roughly, if they're on the walls | no (probe guess) | yes | yes |
| Objects inside the room | misplaced | if on screen | yes | yes |
| Moving objects | frozen until re-baked | if on screen | yes (refit the BVH) | yes |
| Rough surfaces | great | noisy | noisy | uses the probe |
| Needs a denoiser | no | yes | yes | yes |
| Cost grows with | nothing per frame (bake once) | screen pixels | pixels x scene complexity | pixels, plus rays where screen space misses |
GPU cost per pass, on real models: the showcase shows the GPU ms of each pass.
Nearly every shipping engine layers these rather than picking one: probes everywhere as the base, screen space on top for glossy surfaces, and rays where the hardware allows. What differs is how far up the stack a given platform goes. The roughness cutoff is the knob between "cheap and blurry" and "exact and noisy".
Where denoising fits: anything that takes one random sample per pixel (screen space, rays, the hybrid) is noisy and needs a temporal denoiser. Probes come pre-blurred and don't.
WebGPURenderer; the room is explainer from examples/shared, lit by a shadowed spot light at the panel.Reflections.create(renderer, scene, { probes, rayTracing: true, denoiser }): a G-buffer render, the screen-space tracer, rays for its misses, the probe for what neither reaches, FFX's denoiser, and the composite into three's lit image.reflections.ssr.rayTracing off for "screen space + probe"; every pixel sent to the rays for "rays, every pixel"; three's lit image (the probe as its environment) for "probe only".HybridReflections.sourceIndex of the composite: what answered each pixel's ray this frame.reflections.trace.refit() each frame. The probe holds it as it was at the bake.starting...