Joint Non-Local Means (JNLM) Path-Tracing Denoiser
Denoises Monte Carlo path-traced images by averaging pixels whose surrounding radiance patches and auxiliary G-buffer features (albedo, normal, depth) match under variance-normalized squared distance, requiring zero trained weights.
Also known as JNLM, non-local means Monte Carlo denoising, feature-guided NLM denoising
In the family Post-processing, color & imaging, denoising
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | |
| Unity | None found | |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Standard bilateral filters compare single pixels, which breaks down under heavy Monte Carlo noise because individual noisy samples cannot reliably distinguish edges from variance. Joint Non-Local Means (JNLM) instead compares small spatial patches (for example 3×3 or 7×7 neighborhoods) around a center pixel p and each candidate neighbor q inside a larger search window.
The squared patch distance in color space is normalized by the estimated per-pixel sample variance (tracked across progressive path-tracing iterations or dual half-buffers) so high-variance regions filter more aggressively while converged pixels stay sharp. To prevent blurring across geometric discontinuities and fine textures, JNLM combines the color patch distance with joint feature weights computed from noise-free auxiliary AOVs—surface albedo, shading normal, and world depth—taking the strictest similarity criterion across channels.
Each pixel's denoised radiance is the weighted average of its search window. Because the entire algorithm is analytic and needs no neural network weights, it runs cleanly on both WebGPU and WebGL2 with predictable memory use and optional adaptive sampling feedback.
When to choose it
Reach for it when
- progressive path tracer stays grainy without an ai denoiser dependency
- simple bilateral blur smears fine textures and sharp caustic highlights
- denoise monte carlo renders using auxiliary normal albedo and depth guides
- need a pure compute shader denoiser that runs in webgpu with no ml weights
- remove high-variance path tracing noise while preserving repeating surface detail
Choose it when building a lightweight or browser-based progressive path tracer that needs clean, edge-preserving denoising on both WebGPU and WebGL2 without bundling tens of megabytes of neural network weights.
Prefer Intel Open Image Denoise (OIDN) when you can afford neural weights and need crisp reconstruction at 1–4 samples per pixel during interactive camera motion. Prefer Spatiotemporal Variance-Guided Filtering (SVGF) or NVIDIA Real-time Denoisers (ReBLUR, ReLAX) for real-time 60 fps games with motion vectors and temporal reprojection. Prefer Edge-avoiding a-trous wavelet filter when a tiny fixed-cost spatial pass is required.
Field marks
- At very low sample counts (1–4 spp), noisy radiance patches can still smear glossy reflections, caustics, or soft shadow penumbrae
- Extreme fireflies bias both the sample variance estimate and patch distances unless clamped or filtered beforehand
- Over-smoothing of fine bump-mapped or procedural micro-details that are absent from the smooth shading normal and albedo AOVs
- Frame-to-frame temporal flickering on animated sequences because the filter is purely spatial without temporal reprojection
Presets
Joint Non-Local Means (JNLM) — 1-spp noisy path-traced render (left) vs G-buffer patch-matched denoising (right)
{
"P_NOISE": 0.75,
"P_PATCH_SIGMA": 0.45,
"P_GBUF_GUIDE": 1,
"P_SPLIT": 0.48
}Show GLSL (158 lines)
const float P_NOISE = 0.75; // P MC Noise Level [0.15, 1.4, 0.05]
const float P_PATCH_SIGMA = 0.45; // P Patch Bandwidth [0.15, 1.2, 0.05]
const float P_GBUF_GUIDE = 1.00; // P Aux G-Buffer Weight [0.0, 1.5, 0.05]
const float P_SPLIT = 0.48; // P Noisy / JNLM [0.0, 1.0, 0.02]
float hash21(vec2 p) {
p = fract(p * vec2(127.1, 311.7));
p += dot(p, p + 34.5);
return fract(p.x * p.y);
}
// Analytical Cornell-like studio G-buffer + clean radiance
void evalGBuffer(vec2 uv, float t, out vec3 rad, out vec3 alb, out vec3 nrm, out float dep) {
vec3 ro = vec3(0.0, 0.25, 2.25);
vec3 rd = normalize(vec3(uv.x, uv.y - 0.06, -1.5));
vec3 lPos = vec3(0.75 * cos(t * 0.55), 1.15, 0.55 * sin(t * 0.55) + 0.25);
dep = 10.0;
nrm = vec3(0.0, 0.0, 1.0);
alb = vec3(0.18, 0.20, 0.24);
int id = 0;
vec3 hp = vec3(0.0);
// Back wall (z = -1.2)
float tb = (-1.2 - ro.z) / min(rd.z, -1e-4);
if (tb > 0.1 && tb < dep) {
dep = tb; id = 1; hp = ro + rd * tb; nrm = vec3(0.0, 0.0, 1.0);
float wallSplit = step(0.0, hp.x);
alb = mix(vec3(0.84, 0.26, 0.20), vec3(0.20, 0.64, 0.74), wallSplit);
}
// Floor (y = -0.55)
if (rd.y < -0.005) {
float tf = (-0.55 - ro.y) / rd.y;
if (tf > 0.1 && tf < dep) {
dep = tf; id = 2; hp = ro + rd * tf; nrm = vec3(0.0, 1.0, 0.0);
float chk = mod(floor(hp.x * 3.5) + floor(hp.z * 3.5), 2.0);
alb = mix(vec3(0.56, 0.54, 0.50), vec3(0.78, 0.76, 0.72), chk);
}
}
// Left matte-gold sphere
vec3 c1 = vec3(-0.34, -0.18, -0.10);
vec3 o1 = ro - c1;
float b1 = dot(o1, rd), d1 = b1 * b1 - (dot(o1, o1) - 0.37 * 0.37);
if (d1 > 0.0) {
float t1 = -b1 - sqrt(d1);
if (t1 > 0.1 && t1 < dep) {
dep = t1; id = 3; hp = ro + rd * t1; nrm = normalize(hp - c1);
alb = vec3(0.92, 0.72, 0.34);
}
}
// Right ceramic sphere
vec3 c2 = vec3(0.38, -0.25, 0.16);
vec3 o2 = ro - c2;
float b2 = dot(o2, rd), d2 = b2 * b2 - (dot(o2, o2) - 0.30 * 0.30);
if (d2 > 0.0) {
float t2 = -b2 - sqrt(d2);
if (t2 > 0.1 && t2 < dep) {
dep = t2; id = 4; hp = ro + rd * t2; nrm = normalize(hp - c2);
alb = vec3(0.88, 0.89, 0.92);
}
}
vec3 lDir = normalize(lPos - hp);
float lDist = length(lPos - hp);
// Soft analytical sphere shadows on floor & wall
float sh = 1.0;
if (id == 1 || id == 2) {
vec3 toC1 = c1 - hp;
float p1 = max(dot(toC1, lDir), 0.0);
float dist1 = length(toC1 - lDir * p1);
sh *= smoothstep(0.30, 0.44, dist1);
vec3 toC2 = c2 - hp;
float p2 = max(dot(toC2, lDir), 0.0);
float dist2 = length(toC2 - lDir * p2);
sh *= smoothstep(0.24, 0.38, dist2);
}
float ndl = max(dot(nrm, lDir), 0.0);
vec3 bounce = vec3(0.36, 0.16, 0.14) * max(-nrm.x, 0.0) + vec3(0.14, 0.30, 0.36) * max(nrm.x, 0.0) + vec3(0.16, 0.18, 0.22);
rad = alb * (vec3(1.45, 1.32, 1.14) * ndl * sh / (0.4 + 0.22 * lDist * lDist) + bounce);
}
vec3 noisyRadiance(vec2 fc, float noiseAmp, float t, out vec3 alb, out vec3 nrm, out float dep) {
vec2 uv = (fc - 0.5 * iResolution.xy) / iResolution.y;
vec3 rad;
evalGBuffer(uv, t, rad, alb, nrm, dep);
vec2 p = floor(fc);
float fr = floor(t * 10.0) * 0.13;
// Variance-scaled zero-mean Monte Carlo radiance noise (with occasional fireflies)
vec3 n = vec3(
hash21(p + vec2(11.3, fr * 31.7)),
hash21(p + vec2(47.9, fr * 19.3)),
hash21(p + vec2(83.1, fr * 53.1))
) - 0.5;
float spike = step(0.96, hash21(p * 1.31 + vec2(fr * 17.0, 5.1))) * 1.8;
return max(rad + n * noiseAmp * (0.55 + 0.7 * rad) + vec3(spike) * noiseAmp * 0.35 * alb, 0.0);
}
vec3 aces(vec3 x) {
x = max(x, 0.0);
return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
float screenX = fragCoord.x / max(iResolution.x, 1.0);
float split = clamp(P_SPLIT, 0.0, 1.0);
float noiseAmp = clamp(P_NOISE, 0.05, 1.6);
float sigma = clamp(P_PATCH_SIGMA, 0.10, 1.5);
float gGuide = clamp(P_GBUF_GUIDE, 0.0, 2.0);
vec3 cAlb, cNrm;
float cDep;
vec3 centerNoisy = noisyRadiance(fragCoord, noiseAmp, iTime, cAlb, cNrm, cDep);
vec3 col = centerNoisy;
if (screenX >= split) {
// Right: Joint Non-Local Means -- compare 3-tap micro-patches + G-buffer (albedo, normal, depth) across search window
vec3 acc = vec3(0.0);
float wSum = 0.0;
float stepPx = 2.0;
// Precompute tiny 3-point signature around center p
vec3 a0, n0; float d0;
vec3 cpL = noisyRadiance(fragCoord + vec2(-1.5, 0.0), noiseAmp, iTime, a0, n0, d0);
vec3 cpU = noisyRadiance(fragCoord + vec2(0.0, 1.5), noiseAmp, iTime, a0, n0, d0);
for (int iy = -2; iy <= 2; iy++) {
for (int ix = -2; ix <= 2; ix++) {
vec2 q = fragCoord + vec2(float(ix), float(iy)) * stepPx;
vec3 qAlb, qNrm;
float qDep;
vec3 qRad = noisyRadiance(q, noiseAmp, iTime, qAlb, qNrm, qDep);
// Radiance patch distance (3-tap proxy for 3x3 patch)
vec3 qpL = noisyRadiance(q + vec2(-1.5, 0.0), noiseAmp, iTime, a0, n0, d0);
vec3 qpU = noisyRadiance(q + vec2(0.0, 1.5), noiseAmp, iTime, a0, n0, d0);
float dPatch = dot(centerNoisy - qRad, centerNoisy - qRad)
+ dot(cpL - qpL, cpL - qpL)
+ dot(cpU - qpU, cpU - qpU);
float dColorNorm = dPatch / max(3.0 * sigma * sigma * (0.25 + noiseAmp * noiseAmp), 0.01);
// Joint G-buffer feature distance (normal + albedo + depth)
float dNrm = 1.0 - max(dot(cNrm, qNrm), 0.0);
float dAlb = dot(cAlb - qAlb, cAlb - qAlb);
float dDep = abs(cDep - qDep) / max(cDep, 0.25);
float dAux = (dNrm * 18.0 + dAlb * 14.0 + dDep * 24.0) * gGuide;
float w = exp(-dColorNorm - dAux);
acc += qRad * w;
wSum += w;
}
}
col = acc / max(wSum, 1e-4);
}
float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
col = mix(col, vec3(0.95, 0.98, 1.0), sep);
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: MIT — written for this index.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| joint-non-local-means-denoising-live | Tesla T4 1920x1080 | 152× baseline (extreme) · 5.00 ms / 5.28 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| joint-non-local-means-denoising-live | NVIDIA L4 1920x1080 | 143× baseline (extreme) · 2.28 ms / 2.34 ms · 2.2× faster on L4 | opengl-timer-query · Cross-architecture validation |
| joint-non-local-means-denoising-live | NVIDIA A100-SXM4-40GB 1920x1080 | 106× baseline (extreme) · 3.05 ms / 3.07 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Plant Ecosystem Distribution Simulation, Metropolis Light Transport; cited by Disney / Chiang hair and fur BSDF, ReSTIR DI: Spatiotemporal Reservoir Resampling for Direct Lighting, Spatiotemporal Variance-Guided Filtering (SVGF).
Crosses
- Dispersive manifold caustics denoised with joint NLM: Rainbow glass caustics converged in seconds instead of hours. Hero-wavelength spectral dispersion supplies exact refractive indices per sample, manifold next-event estimation solves deterministic refractive chains straight to small lights, and joint non-local means removes residual fireflies without blurring sharp spectral fringes.
- Unidirectional Path Tracing: Consumes progressive HDR radiance, sample variance, albedo, and normal AOVs to produce converged-looking renders at far fewer samples.
- Owen-scrambled Sobol and low-discrepancy sampling: Well-stratified low-discrepancy samples yield lower-noise variance estimates that improve NLM patch-similarity accuracy.
Sources
- primaryFabrice Rousselle, Claude Knaus, Matthias Zwicker (2012). Adaptive rendering with non-local means filtering. ACM Transactions on Graphics.Verified via crossref · 2026-11-30doi:10.1145/2366145.2366214
- implementationpissang (2026). pissang/mutracer. WebGPU physically based path tracerGitHub API · license MIT · 2026-11-30