---
id: "continuous-wavelength-spectral-dispersion"
title: "Continuous-Wavelength Hero and Single-Wavelength Spectral Dispersion"
aliases: [hero wavelength spectral sampling, HWSS, continuous-wavelength dispersion, spectral dispersion path tracing]
domain: "materials"
stage: "material"
realtime: "interactive"
platforms: [webgpu, webgl2, desktop-gpu, cuda, cpu]
year_introduced: 2014
inputs: [material-params, radiance]
outputs: [radiance]
style: "photoreal"
dynamic: "dynamic"
cost: "medium"
authority: "Wilkie et al., 2014"
url: "https://texelatlas.vercel.app/t/continuous-wavelength-spectral-dispersion/"
sources_verified_at: "2026-11-30"
---
# Continuous-Wavelength Hero and Single-Wavelength Spectral Dispersion (Wilkie et al., 2014)

> Samples continuous visible wavelengths along refractive paths—either as a multi-wavelength hero bundle or a single wavelength when dispersion splits rays—so glass, prisms, and gemstones render smooth rainbow caustics without discrete RGB banding.

## Reach for it when

- rgb rendering misses rainbow prism dispersion through glass and diamonds
- three-channel caustics show ugly red green blue banding instead of spectra
- need physically accurate glass chromatic dispersion in a path tracer
- sample continuous visible wavelengths with hero wavelength weighting
- convert spectral radiance cleanly to linear rgb without color bias

## How it works

Dispersive dielectrics such as crystal glass and diamonds refract short blue wavelengths more strongly than long red wavelengths, governed by a wavelength-dependent index of refraction `n(λ)` (commonly parameterized via Cauchy or Sellmeier equations and an Abbe number). Splitting rays into only three fixed R, G, and B channels produces stark three-color stair-stepping instead of a smooth spectrum.

**Hero Wavelength Spectral Sampling** (Wilkie et al. 2014) transports a stratified tuple of `N` continuous wavelengths (often 4) together along every non-dispersive path segment, using one randomly selected **hero wavelength** `λ_h` to drive directional BSDF sampling and weighting all `N` companion wavelengths via balance-heuristic multiple importance sampling. Whenever a path encounters a dispersive specular interface where Snell's law depends on `λ`, companion wavelengths cannot share the refracted direction, so their throughput collapses to zero and the path continues purely at the hero wavelength `λ_h`.

Lightweight RGB path tracers adopt a **single-wavelength dispersion** variant on demand: camera paths carry RGB until they hit a dispersive material, at which point a continuous wavelength `λ ∈ [400, 700]` nm is importance-sampled from a CIE color-matching inverse CDF table, refracted using `n(λ)`, and weighted back into linear sRGB so white light integrates neutrally on average.

## When to use it

Choose it in physically based path tracers whenever glass, prisms, crystal chandeliers, camera lenses, or gemstones must exhibit smooth rainbow dispersion and spectral caustics without discrete R/G/B fringes.

Prefer [chromatic-aberration](chromatic-aberration) post-processing when you only want cheap screen-space lens fringing in a real-time rasterizer. Prefer [thin-film-iridescence](thin-film-iridescence) for wave-interference soap bubbles and oil slicks where phase shift rather than bulk refraction drives color separation. Pair with [spectral-upsampling-sigmoid](spectral-upsampling-sigmoid) when running a full spectral renderer on RGB textures.

## Cost

medium — Hero-wavelength bundles add SIMD-friendly per-bounce spectral arithmetic; on-demand single-wavelength dispersion incurs near-zero overhead on non-dispersive paths but introduces chromatic Monte Carlo noise that needs extra samples or denoising.
Measured GPU Weight: 24.91× baseline (heavy) — 0.8197 ms median / 0.8307 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 17.69× baseline (moderate) — 0.2813 ms median (2.91× faster on L4).
Ampere A100 scaling: 15.76× baseline (moderate) — 0.454 ms median (1.81× faster on A100).

## Failure modes

- Single-wavelength collapse after dispersive refraction introduces high-frequency rainbow color noise that converges more slowly than luminance noise
- RGB-embedded continuous-wavelength dispersion clamps out-of-gamut spectral XYZ values into sRGB, sacrificing strict colorimetric accuracy for saturated rainbows
- Smooth spectral caustics still suffer high variance under unidirectional path tracing unless combined with caustic photon mapping, light tracing, or manifold sampling
- Incorrect Abbe number parameterization or negative Cauchy terms can produce unphysical refractive indices outside the visible band

## Dataflow

- Inputs: material-params, radiance
- Outputs: radiance
- Platforms: webgpu, webgl2, desktop-gpu, cuda, cpu

## Presets

### Continuous-Wavelength Spectral Dispersion — 3-band RGB dispersion (left) vs continuous hero-wavelength Cauchy spectrum (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_DISPERSION": 0.14,
  "P_IOR_BASE": 1.62,
  "P_ROT_SPEED": 0.55,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_DISPERSION = 0.14; // P Cauchy Dispersion [0.02, 0.28, 0.01]
const float P_IOR_BASE = 1.62; // P Base Glass IOR [1.35, 2.15, 0.02]
const float P_ROT_SPEED = 0.55; // P Prism Spin [0.0, 2.2, 0.05]
const float P_SPLIT = 0.48; // P RGB / Spectral Split [0.0, 1.0, 0.02]

mat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }

// Smooth CIE-inspired spectral wavelength-to-linear-RGB response for lambda in [0, 1] (400nm -> 700nm)
vec3 spectralRGB(float t) {
  vec3 c = clamp(vec3(
    1.5 - abs(t - 0.78) * 3.6 + 0.35 * exp(-pow((t - 0.12) * 5.0, 2.0)),
    1.45 - abs(t - 0.48) * 3.4,
    1.5 - abs(t - 0.18) * 3.6
  ), 0.0, 1.0);
  return c * c;
}

// Faceted octagonal crystal gem / optical prism SDF
float mapCrystal(vec3 p, float spin) {
  vec3 q = p;
  q.xz = rot2(spin * 0.52) * q.xz;
  q.yz = rot2(0.32) * q.yz;
  vec3 aq = abs(q);
  float d1 = max(aq.x + aq.z * 0.414, aq.z + aq.x * 0.414) - 0.58;
  float d2 = (aq.x + aq.y * 0.85 + aq.z) * 0.68 - 0.66;
  float d3 = aq.y - 0.72;
  return max(max(d1, d2), d3) * 0.88;
}

vec3 calcNormal(vec3 p, float spin) {
  vec2 e = vec2(0.002, 0.0);
  return normalize(vec3(
    mapCrystal(p + e.xyy, spin) - mapCrystal(p - e.xyy, spin),
    mapCrystal(p + e.yxy, spin) - mapCrystal(p - e.yxy, spin),
    mapCrystal(p + e.yyx, spin) - mapCrystal(p - e.yyx, spin)
  ));
}

// High-contrast studio lightbox environment so chromatic dispersion fringes read crisply
vec3 studioEnv(vec3 d) {
  vec3 bg = mix(vec3(0.02, 0.03, 0.05), vec3(0.10, 0.14, 0.22), smoothstep(-0.4, 0.6, d.y));
  float strip1 = smoothstep(0.08, 0.02, abs(d.x - 0.38)) * smoothstep(-0.3, 0.5, d.y);
  float strip2 = smoothstep(0.10, 0.02, abs(d.x + 0.45)) * smoothstep(-0.2, 0.6, d.y);
  float keyOrb = pow(max(dot(d, normalize(vec3(0.55, 0.72, -0.45))), 0.0), 42.0);
  float horizonBand = exp(-abs(d.y + 0.08) * 16.0) * (0.4 + 0.6 * step(0.0, sin(atan(d.z, d.x) * 6.0)));
  return bg + vec3(2.8, 2.75, 2.65) * (strip1 + strip2 * 0.8 + keyOrb * 1.8) + vec3(0.9, 0.95, 1.0) * horizonBand * 0.85;
}

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) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  float screenX = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  bool isContinuous = screenX >= split;
  float disp = clamp(P_DISPERSION, 0.01, 0.32);
  float iorBase = clamp(P_IOR_BASE, 1.2, 2.3);
  float spin = iTime * max(P_ROT_SPEED, 0.0);

  vec3 ro = vec3(0.0, 0.10, 2.35);
  vec3 rd = normalize(vec3(uv, -1.55));

  vec3 col = mix(vec3(0.018, 0.022, 0.036), vec3(0.052, 0.062, 0.095), smoothstep(-0.55, 0.55, uv.y));
  // Soft caustic spectral fan cast behind the prism onto backdrop
  float causticAngle = atan(uv.y + 0.12, uv.x + 0.02);
  float causticBeam = exp(-abs(uv.y + 0.24 - uv.x * 0.18) * 14.0) * smoothstep(0.18, 0.65, abs(uv.x));
  if (isContinuous) {
    float wl = clamp(0.5 + (uv.y + 0.24 - uv.x * 0.18) * 3.8, 0.0, 1.0);
    col += spectralRGB(wl) * causticBeam * 0.38;
  } else {
    float dY = uv.y + 0.24 - uv.x * 0.18;
    vec3 rgbBand = vec3(exp(-pow((dY - 0.04) * 34.0, 2.0)), exp(-pow(dY * 34.0, 2.0)), exp(-pow((dY + 0.04) * 34.0, 2.0)));
    col += rgbBand * causticBeam * 0.42;
  }

  float t = 0.0;
  bool hit = false;
  for (int i = 0; i < 56; i++) {
    float d = mapCrystal(ro + rd * t, spin);
    if (d < 0.002) { hit = true; break; }
    t += d;
    if (t > 5.0) break;
  }

  if (hit) {
    vec3 p = ro + rd * t;
    vec3 n = calcNormal(p, spin);
    vec3 reflD = reflect(rd, n);
    float ndv = max(dot(n, -rd), 0.0);
    float f0 = pow((iorBase - 1.0) / (iorBase + 1.0), 2.0);
    float fres = f0 + (1.0 - f0) * pow(1.0 - ndv, 5.0);

    vec3 transCol = vec3(0.0);
    if (!isContinuous) {
      // Left: Discrete 3-channel RGB refraction (produces distinct red/green/blue chromatic split!)
      for (int c = 0; c < 3; c++) {
        float fc = float(c);
        float ior = iorBase + (fc - 1.0) * disp * 1.15;
        vec3 rIn = refract(rd, n, 1.0 / ior);
        // Approximate second exit refraction through opposite crystal wall
        vec3 pExit = p + rIn * 0.72;
        vec3 nExit = -calcNormal(pExit, spin);
        vec3 rOut = refract(rIn, nExit, ior);
        if (length(rOut) < 0.01) rOut = reflect(rIn, nExit);
        vec3 s = studioEnv(normalize(rOut));
        if (c == 0) transCol.r = s.r;
        else if (c == 1) transCol.g = s.g;
        else transCol.b = s.b;
      }
    } else {
      // Right: Continuous 12-wavelength hero spectral quadrature using Cauchy n(lambda) = A + B/lambda^2
      vec3 normW = vec3(0.0);
      for (int k = 0; k < 12; k++) {
        float wl = (float(k) + 0.5) / 12.0; // 0 = 400nm violet, 1 = 700nm red
        float lam = mix(0.40, 0.70, wl);
        float cauchy = (1.0 / (lam * lam) - 1.0 / (0.55 * 0.55)) * 0.24;
        float ior = iorBase + cauchy * disp * 1.45;
        vec3 rIn = refract(rd, n, 1.0 / max(ior, 1.05));
        vec3 pExit = p + rIn * 0.72;
        vec3 nExit = -calcNormal(pExit, spin);
        vec3 rOut = refract(rIn, nExit, max(ior, 1.05));
        if (length(rOut) < 0.01) rOut = reflect(rIn, nExit);
        vec3 wRGB = spectralRGB(wl);
        float envLum = dot(studioEnv(normalize(rOut)), vec3(0.28, 0.54, 0.18));
        transCol += wRGB * envLum;
        normW += wRGB;
      }
      transCol /= max(normW, vec3(1e-4));
    }

    vec3 reflCol = studioEnv(reflD);
    col = mix(transCol * 1.25, reflCol, clamp(fres * 1.1, 0.08, 0.92));
  }

  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
  col = mix(col, vec3(0.95, 0.97, 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.

## Combines with

- [Spectral upsampling with sigmoid polynomials](https://texelatlas.vercel.app/t/spectral-upsampling-sigmoid.md): Converts RGB albedo textures into smooth continuous reflectance spectra evaluated at each hero and companion wavelength.
- [OpenPBR Surface](https://texelatlas.vercel.app/t/openpbr-surface.md): Drives wavelength-dependent dielectric refraction directly from OpenPBR's transmission dispersion scale and Abbe number parameters.

## Combination ideas

- [Dispersive manifold caustics denoised with joint NLM](https://texelatlas.vercel.app/ideas/spectral-mnee-jnlm-caustics/)

## Sources

1. [primary] A. Wilkie, S. Nawaz, M. Droske, A. Weidlich, J. Hanika (2014) Hero Wavelength Spectral Sampling. Computer Graphics Forum. https://doi.org/10.1111/cgf.12419 (verified via crossref on 2026-11-30)
2. [implementation] pissang (2026) pissang/mutracer. https://github.com/pissang/mutracer License: MIT. (verified via github on 2026-11-30)

## Cite this entry

Texel. "Continuous-Wavelength Hero and Single-Wavelength Spectral Dispersion." https://texelatlas.vercel.app/t/continuous-wavelength-spectral-dispersion/ (accessed 2026-12-01).
