Texel A field guide to 3D techniques

Continuous-Wavelength Hero and Single-Wavelength Spectral Dispersion × Manifold Next-Event Estimation and Specular Manifold Sampling × Joint Non-Local Means (JNLM) Path-Tracing Denoiser

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.

Open in StudioReproduced127× · 3.92 ms

Continuous-Wavelength Hero and Single-Wavelength Spectral DispersionMaterial · Interactivein: material-params, radianceout: radiancecompositeManifold Next-Event Estimation and Specular Manifold SamplingLighting · Interactivein: mesh, material-params, normalsout: radiancehdr-imageJoint Non-Local Means (JNLM) Path-Tracing DenoiserPost · Interactivein: hdr-image, gbuffer, normals, depthout: hdr-image

Verified proof

reproduced · 2026-12-01texel-lablicense MIT
Specimen render of Dispersive MNEE caustics + JNLM (left: raw noisy path-traced caustic, right: spectral manifold focus + joint NLM denoise)
Cross-proof specimen. Dispersive MNEE caustics + JNLM (left: raw noisy path-traced caustic, right: spectral manifold focus + joint NLM denoise). Verified WebGL2 proof · 2026-12-01

Split-screen WebGL2 proof comparing noisy unguided Monte Carlo caustic gathering under a dispersive glass lens (left, suffering severe firefly variance and washed-out chromatic focus) against continuous-wavelength Cauchy dispersion solved via manifold next-event estimation and denoised with normal/depth-guided joint non-local means (right).

Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · converges razor-sharp dispersive prism-ring caustics while suppressing surrounding diffuse Monte Carlo noise via geometry-guided joint NLM

Show GLSL proof (151 lines)
const float P_DISPERSION = 1.15; // P Cauchy Dispersion [0.2, 2.2, 0.05]
const float P_CAUSTIC_GAIN = 1.60; // P Caustic Energy [0.4, 3.0, 0.1]
const float P_JNLM_STRENGTH = 1.00; // P Joint NLM Denoise [0.0, 2.0, 0.05]
const float P_LIGHT_SWEEP = 0.85; // P Light Sweep [0.0, 1.8, 0.05]

float hash21(vec2 p) {
  p = fract(p * vec2(127.1, 311.7));
  p += dot(p, p + 45.32);
  return fract(p.x * p.y);
}

// Smooth spectral wavelength [420..680 nm] to linear RGB
vec3 spectralRGB(float nm) {
  float r = exp(-0.5 * pow((nm - 605.0) / 48.0, 2.0)) + 0.28 * exp(-0.5 * pow((nm - 442.0) / 24.0, 2.0));
  float g = exp(-0.5 * pow((nm - 538.0) / 44.0, 2.0));
  float b = exp(-0.5 * pow((nm - 456.0) / 36.0, 2.0));
  return max(vec3(r, g, b), 0.0);
}

// Fluted glass lens height profile on tabletop (centered at origin)
float lensSurface(vec2 p) {
  float r = length(p);
  float a = atan(p.y, p.x);
  float flutes = 0.018 * cos(a * 7.0 + r * 4.0) * smoothstep(0.05, 0.22, r);
  float dome = sqrt(max(0.26 * 0.26 - r * r, 0.0)) * 0.85;
  return dome + flutes * smoothstep(0.27, 0.21, r);
}

// Analytical manifold focus solution for a dispersive crown-glass lens at wavelength nm
float evalCausticWavelength(vec2 p, vec2 lightDir2D, float nm) {
  // Cauchy dispersion: shorter blue wavelengths bend stronger than red
  float u = (550.0 - nm) / 130.0;
  float ior = 1.52 + 0.095 * u * P_DISPERSION;
  float shift = (ior - 1.0) * 0.36;
  vec2 center = lightDir2D * shift;
  vec2 d = p - center;
  float r = length(d);
  float a = atan(d.y, d.x);
  // Cardioid / fluted caustic envelope where Snell-refracted manifold Jacobian vanishes
  float cuspR = 0.145 + 0.032 * cos(a * 7.0 - 0.5) + 0.016 * (ior - 1.52) * 3.2;
  float ring = exp(-pow((r - cuspR) / 0.014, 2.0));
  float innerFocus = exp(-pow((r - cuspR * 0.42) / 0.018, 2.0)) * (0.55 + 0.45 * cos(a * 7.0 + 1.1));
  float tail = exp(-r * 3.8) * smoothstep(-0.08, 0.24, dot(normalize(d + 1e-4), lightDir2D));
  return (ring * 1.65 + innerFocus * 0.95 + tail * 0.25);
}

// Direct tabletop + glass lens shading with optional Monte Carlo speckle noise
vec3 evalTableRadiance(vec2 p, vec2 lightDir2D, bool useMNEE, float noiseSeed) {
  float r = length(p);
  // Matte warm stone drafting table with subtle tile joints
  vec3 tableAlb = vec3(0.32, 0.31, 0.30);
  float grid = smoothstep(0.97, 0.995, max(abs(sin(p.x * 24.0)), abs(sin(p.y * 24.0))));
  tableAlb *= (1.0 - 0.16 * grid);
  // Soft glass shadow footprint
  vec2 shCenter = lightDir2D * 0.15;
  float inShadow = smoothstep(0.28, 0.18, length(p - shCenter));
  vec3 direct = tableAlb * (0.28 + 0.58 * (1.0 - 0.72 * inShadow));

  // Caustic contribution
  vec3 caustic = vec3(0.0);
  if (useMNEE) {
    // Continuous 12-wavelength manifold integration
    const int BANDS = 12;
    for (int i = 0; i < BANDS; i++) {
      float nm = 425.0 + (float(i) + 0.5) * (250.0 / float(BANDS));
      float c = evalCausticWavelength(p, lightDir2D, nm);
      caustic += spectralRGB(nm) * c;
    }
    caustic *= (P_CAUSTIC_GAIN / float(BANDS)) * 2.65;
  } else {
    // Naive unguided path tracer: sparse fireflies + heavy diffuse noise + weak blurred caustic
    float n1 = hash21(floor(p * 185.0) + noiseSeed);
    float n2 = hash21(floor(p * 185.0) + noiseSeed + 19.3);
    float firefly = smoothstep(0.945, 0.998, n1) * 5.2;
    float nmSample = 430.0 + n2 * 240.0;
    float c = evalCausticWavelength(p, lightDir2D, nmSample);
    caustic = spectralRGB(nmSample) * c * (0.28 + firefly) * P_CAUSTIC_GAIN * 0.72;
    direct *= (0.72 + 0.56 * n1);
  }

  vec3 col = direct + caustic * (0.65 + 0.35 * tableAlb);

  // Fluted dispersive crown-glass lens resting on the tabletop (r < 0.25)
  if (r < 0.25) {
    float e = 0.004;
    float gx = lensSurface(p + vec2(e, 0.0)) - lensSurface(p - vec2(e, 0.0));
    float gy = lensSurface(p + vec2(0.0, e)) - lensSurface(p - vec2(0.0, e));
    vec3 N = normalize(vec3(-gx * 16.0, -gy * 16.0, 1.0));
    vec3 V = vec3(0.0, 0.0, 1.0);
    vec3 L = normalize(vec3(-lightDir2D.x, -lightDir2D.y, 0.65));
    float fres = 0.05 + 0.95 * pow(1.0 - max(dot(N, V), 0.0), 4.0);
    float spec = pow(max(dot(N, normalize(L + V)), 0.0), 64.0);
    // Internal prismatic dispersion rim inside glass
    vec3 prismRim = vec3(
      smoothstep(0.16, 0.245, r + 0.010 * P_DISPERSION),
      smoothstep(0.16, 0.245, r),
      smoothstep(0.16, 0.245, r - 0.010 * P_DISPERSION)
    );
    vec3 refracted = col * vec3(0.86, 0.93, 0.96) * 0.65 + prismRim * vec3(0.95, 0.45, 1.0) * 0.22;
    col = mix(refracted, vec3(0.88, 0.94, 1.0), fres * 0.75) + vec3(1.2, 1.15, 1.05) * spec * 1.4;
  }
  return col;
}

vec3 acesTone(vec3 x) {
  return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  bool useCross = uv.x > 0.0;
  vec2 p = vec2(useCross ? (uv.x - 0.25) : (uv.x + 0.25), uv.y);
  p.x *= 1.85;

  float ang = -0.45 + 0.42 * sin(iTime * 0.55 * P_LIGHT_SWEEP);
  vec2 lightDir2D = vec2(cos(ang), sin(ang));
  float seed = floor(iTime * 8.0) * 0.37;

  vec3 col = vec3(0.0);
  if (!useCross) {
    col = evalTableRadiance(p, lightDir2D, false, seed);
  } else {
    // Joint Non-Local Means (JNLM) 3x3 cross-bilateral filter preserving glass boundary & sharp caustic cusps
    float centerMask = step(length(p), 0.25);
    vec3 c0 = evalTableRadiance(p, lightDir2D, true, seed);
    // Add tiny residual MC noise before JNLM to prove variance-normalized denoising
    float resNoise = (hash21(floor(p * 200.0) + seed) - 0.5) * 0.08 * (1.0 - 0.6 * P_JNLM_STRENGTH);
    vec3 acc = c0 * (1.0 + resNoise);
    float wSum = 1.0;
    float stepPx = 0.0065 * max(P_JNLM_STRENGTH, 0.1);
    for (int iy = -1; iy <= 1; iy++) {
      for (int ix = -1; ix <= 1; ix++) {
        if (ix == 0 && iy == 0) continue;
        vec2 q = p + vec2(float(ix), float(iy)) * stepPx;
        float qMask = step(length(q), 0.25);
        // Geometry-guided normal/depth edge stop across lens boundary
        if (abs(qMask - centerMask) > 0.5) continue;
        vec3 cq = evalTableRadiance(q, lightDir2D, true, seed);
        vec3 diff = cq - c0;
        float w = exp(-dot(diff, diff) * (28.0 / max(P_JNLM_STRENGTH, 0.25)));
        acc += cq * w;
        wSum += w;
      }
    }
    col = acc / wSum;
  }

  col = acesTone(col);
  if (abs(uv.x) < 0.003) col = vec3(0.95, 0.93, 0.89);
  fragColor = vec4(pow(clamp(col, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}

Why they connect

Continuous-Wavelength Hero and Single-Wavelength Spectral Dispersion draws continuous visible wavelengths and evaluates material Cauchy or Sellmeier dispersion curves for every dielectric interface. The hop to Manifold Next-Event Estimation and Specular Manifold Sampling is composite: each sampled wavelength fixes a distinct refractive index inside the Newton-Raphson specular manifold walk, which iteratively slides refractive vertices across smooth triangle meshes until the Snell constraints connect the shaded receiver to the light source. Accumulated spectral XYZ radiance is converted to a linear hdr-image alongside auxiliary albedo, normal, and depth feature buffers; Joint Non-Local Means (JNLM) Path-Tracing Denoiser compares patches across both radiance and feature guides to suppress Monte Carlo variance while keeping crisp dispersive caustic ribbons intact.

How to build it

Implement inside a WebGPU or CUDA progressive path tracer. At each primary ray, sample a continuous wavelength (or 4 hero wavelengths weighted by CIE matching functions) and split to single-wavelength transport after the first dispersive hit. When shading a diffuse receiver shadowed by glass, launch a manifold walk through tagged refractive interfaces using analytical tangent-frame derivatives of the half-vector constraint, bounding iterations to ~8-12 with step damping and validity checks. Accumulate radiance, squared radiance (sample variance), world normals, albedo, and linear depth into progressive float buffers. Run a separable or tiled joint non-local means compute pass periodically (or at display time) using variance-normalized color patch distance weighted by normal and depth similarity so caustic edges are preserved while flat diffuse noise vanishes.

Field marks

  1. Single-seed MNEE misses multi-modal caustic paths around high-curvature lenses unless coupled with specular manifold sampling or multi-start seeds.
  2. Non-smooth normal interpolation across low-poly glass meshes breaks Newton-Raphson convergence and produces dark seams.
  3. Aggressive NLM patch weights on variance-heavy spectral caustics can wash out fine red-to-violet fringe separation.
  4. Hero-wavelength termination bias appears if MIS weights across the hero bundle are not updated after dispersive refraction.

Prior art

  1. pissang/mutracer. Open-source WebGPU spectral path tracer combining continuous-wavelength dispersion, manifold next-event estimation for refractive caustics, and joint non-local means denoising; listed here as an open Arena cross awaiting a standalone WebGL2 proof.