Denoising and upscaling

How the denoiser, upscaler, BVH, downsampler and motion-vector libraries fit with this one.

One stochastic ray per pixel is noisy. The library does not hide that: it makes the noise cheap and hands it to a denoiser. Several sibling libraries from the same group do the other jobs, so each one stays small.

LibraryIts jobHow it meets this one
denoiser (^2.0.0 on npm)Denoises. denoiser/ffx has a real-time temporal reflection denoiser, FfxReflectionDenoiser. The root export is OIDN, for path-traced frames.Plugs in through the denoise seam. You pass it to HybridReflections.
@pmndrs/upscalerTemporal upscaling and anti-aliasing of the final frame.Runs after the composite, on the whole image. Reflections are not special to it.
@pmndrs/raytracer and @pmndrs/bvhA WGSL ray-tracing core, and the BVH builders and ray walk under it. Neither knows an engine.The ray-traced provider, behind the trace seam. @pmndrs/raytracer is the only one.
@pmndrs/pathtracerA path tracer built on the raytracer.Only the showcase's compare page uses it, as the reference image. Not a dependency.
@pmndrs/downsamplerA fast GPU depth downsample (SPD style).Builds the depth pyramid the screen-space tracer marches. A dependency, not something you call.
@pmndrs/motion-vectorsMotion vectors for engines that do not produce them.The denoiser and the upscaler both read per-pixel motion. This is where it can come from when your engine has no velocity output.

The denoise seam

HybridReflections takes any object shaped like a TemporalDenoiser<SpecularInputs> from the denoiser's core. It receives the radiance, the hit distance, the guides (depth, normal, roughness, motion) and the camera. FfxReflectionDenoiser fits as is.

pnpm add denoiser
const hybrid = new HybridReflections(ssr, { denoiser });
hybrid.denoise = true; // toggle at any time

The denoiser is an optional peer and never a dependency. That keeps this package small and lets you swap in another denoiser that speaks the same interface.

Note

Without a denoiser, the resolve runs undenoised. That still works, but rough glossy surfaces and traced reflections shimmer much more. The live examples run with it.

Match the denoiser's roughness gate to the tracer's. The tracer skips pixels rougher than roughnessThreshold (perceptual). The denoiser compares alpha, which is perceptual roughness squared. If you use the default of 0.447, give the denoiser 0.447 * 0.447.

Upscaling

Run the reflection passes at a lower render size and let an upscaler rebuild the display size. The G-buffer, reflections and denoiser all run at the render size, so every reflection pass gets cheaper with the pixel count. The upscaler needs motion vectors and jittered cameras: ssr.render(scene, camera, { jitter }) takes the jitter.

At ratio 1 the upscaler works as temporal anti-aliasing, and that alone calms a lot of residual shimmer. See Flicker and stability.

Reflections can also run at half resolution on their own (reflectionResolution: 'half', or the performance preset). That is a separate trade. The tracer and denoiser run on one pixel per 2x2 quad, and a joint bilateral filter upsamples the result. It saves more than most settings, at the cost of crisp mirror edges. The upscaler is the better first choice when you have to pick one.

The trace seam

The ray-traced fallback does not care which BVH you use. A provider is a WGSL function that returns the first hit, plus a bind group. The shipped provider is built on @pmndrs/raytracer. See Ray-traced fallback.

Live examples