Stylized nonlinear Monte Carlo rendering × Neural Radiance Caching
Toon-banded bounce light, learned live. Real-time GI whose indirect light is banded or thresholded at every bounce. The cache returns a converged average per surface point, so the artist's nonlinear ramp acts on an expectation instead of on single noisy samples.
Open in StudioReproduced26.1× · 0.808 ms
Verified proof

Split-screen WebGL2 proof comparing standard linear physically-based multi-bounce Cornell-box GI (left, producing smooth low-contrast color bleed gradients) against stylized non-linear Monte Carlo transport coupled with a smoothstep-banded radiance cache where both direct terminators and red/cyan multi-bounce wall reflections quantize into lush graphic anime/gouache light bands (right).
Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · converts continuous multi-bounce GI into crisp, temporally coherent toon-banded direct and indirect color bleed without muddy linear gradients
Show GLSL proof (169 lines)
const float P_BANDS = 3.0; // P Quantization Bands [2.0, 6.0, 1.0]
const float P_SOFTNESS = 0.14; // P Ramp Softness [0.02, 0.35, 0.01]
const float P_BOUNCE_GAIN = 1.45; // P Indirect Bounce Gain [0.4, 2.6, 0.05]
const float P_LIGHT_SWING = 0.85; // P Ceiling Light Swing [0.0, 1.6, 0.05]
// Smooth artist-paintable non-linear quantization ramp f(x) so the radiance cache fixed point stays smooth
float stylizedRamp(float x, float bands, float softness) {
float v = clamp(x, 0.0, 1.0) * bands;
float idx = floor(v);
float f = fract(v);
float s = smoothstep(0.5 - softness, 0.5 + softness, f);
return (idx + s) / bands;
}
vec3 stylizedColor(vec3 rad, float bands, float softness) {
float lum = max(dot(rad, vec3(0.2126, 0.7152, 0.0722)), 1e-4);
float qLum = stylizedRamp(lum / (1.0 + lum * 0.45), bands, softness) * 1.35;
// Preserve chromatic hue of colored wall bounce while quantizing luminance bands
vec3 chroma = rad / lum;
return chroma * qLum;
}
float sdBox3(vec3 p, vec3 b) {
vec3 q = abs(p) - b;
return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
}
// Cornell box scene: returns (distance, materialID)
// 1=white walls, 2=crimson left wall, 3=teal right wall, 4=matte cream sphere, 5=tall plinth
vec2 mapCornell(vec3 p) {
float d = 1e5;
float mat = 1.0;
// Floor, ceiling, back wall
float floorD = p.y + 0.65;
if (floorD < d) { d = floorD; mat = 1.0; }
float ceilD = 0.65 - p.y;
if (ceilD < d) { d = ceilD; mat = 1.0; }
float backD = p.z + 0.75;
if (backD < d) { d = backD; mat = 1.0; }
// Crimson left wall & turquoise right wall
float leftD = p.x + 0.78;
if (leftD < d) { d = leftD; mat = 2.0; }
float rightD = 0.78 - p.x;
if (rightD < d) { d = rightD; mat = 3.0; }
// Matte sculptural sphere
float sphD = length(p - vec3(-0.22, -0.34, -0.08)) - 0.31;
if (sphD < d) { d = sphD; mat = 4.0; }
// Tall architectural plinth on right
float boxD = sdBox3(p - vec3(0.30, -0.20, -0.22), vec3(0.18, 0.45, 0.18));
if (boxD < d) { d = boxD; mat = 5.0; }
return vec2(d, mat);
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(0.004, -0.004);
return normalize(
e.xyy * mapCornell(p + e.xyy).x +
e.yyx * mapCornell(p + e.yyx).x +
e.yxy * mapCornell(p + e.yxy).x +
e.xxx * mapCornell(p + e.xxx).x
);
}
float softShadow(vec3 ro, vec3 rd, float maxT) {
float res = 1.0;
float t = 0.03;
for (int i = 0; i < 20; i++) {
if (t > maxT) break;
float h = mapCornell(ro + rd * t).x;
if (h < 0.002) return 0.0;
res = min(res, 6.5 * h / t);
t += clamp(h, 0.02, 0.14);
}
return clamp(res, 0.0, 1.0);
}
// Multi-bounce learned radiance cache query: estimates colored indirect irradiance from red/teal walls & floor
vec3 evalBounceCache(vec3 p, vec3 n, vec3 lightPos, bool stylized) {
// Wall proximity & hemisphere form factors from crimson (-x) and teal (+x) bounce walls
float fRed = clamp((0.78 - p.x) / 1.56, 0.0, 1.0);
float fTeal = clamp((0.78 + p.x) / 1.56, 0.0, 1.0);
float nRed = clamp(dot(n, vec3(-1.0, 0.12, 0.0)) * 0.65 + 0.35, 0.0, 1.0);
float nTeal = clamp(dot(n, vec3(1.0, 0.12, 0.0)) * 0.65 + 0.35, 0.0, 1.0);
float nFloor = clamp(dot(n, vec3(0.0, -1.0, 0.0)) * 0.55 + 0.35, 0.0, 1.0);
// Modulate bounce energy by ceiling light proximity to each colored wall
float lRed = 1.0 / (1.0 + 1.4 * pow(lightPos.x + 0.78, 2.0));
float lTeal = 1.0 / (1.0 + 1.4 * pow(lightPos.x - 0.78, 2.0));
vec3 bRed = vec3(1.15, 0.16, 0.12) * pow(fRed, 1.35) * nRed * lRed;
vec3 bTeal = vec3(0.10, 0.85, 0.96) * pow(fTeal, 1.35) * nTeal * lTeal;
vec3 bWarm = vec3(0.45, 0.42, 0.38) * nFloor * 0.38;
// Contact AO cavity damping
float ao = clamp(mapCornell(p + n * 0.10).x / 0.10, 0.18, 1.0);
vec3 rawBounce = (bRed + bTeal + bWarm) * ao * P_BOUNCE_GAIN;
if (!stylized) return rawBounce;
// Apply non-linear smoothstep quantization inside the radiance cache target
vec3 qRed = vec3(1.18, 0.18, 0.14) * stylizedRamp(pow(fRed, 1.15) * nRed * lRed * P_BOUNCE_GAIN * 0.95, P_BANDS, P_SOFTNESS);
vec3 qTeal = vec3(0.10, 0.90, 1.02) * stylizedRamp(pow(fTeal, 1.15) * nTeal * lTeal * P_BOUNCE_GAIN * 0.95, P_BANDS, P_SOFTNESS);
vec3 qAmb = vec3(0.32, 0.30, 0.28) * stylizedRamp(ao * 0.85, P_BANDS, P_SOFTNESS);
return (qRed + qTeal) * (0.45 + 0.55 * ao) + qAmb * 0.55;
}
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 useStylized = uv.x > 0.0;
vec2 suv = vec2(useStylized ? (uv.x - 0.25) : (uv.x + 0.25), uv.y);
suv.x *= 1.85;
vec3 ro = vec3(0.0, 0.02, 1.55);
vec3 rd = normalize(vec3(suv.x * 0.92, suv.y * 0.92, -1.35));
vec3 lightPos = vec3(0.28 * sin(iTime * 0.8 * P_LIGHT_SWING), 0.61, -0.18 + 0.14 * cos(iTime * 0.6 * P_LIGHT_SWING));
float t = 0.0;
float mat = 0.0;
bool hit = false;
for (int i = 0; i < 48; i++) {
vec2 r = mapCornell(ro + rd * t);
if (r.x < 0.002) { hit = true; mat = r.y; break; }
t += r.x * 0.95;
if (t > 4.5) break;
}
vec3 col = vec3(0.04, 0.04, 0.05);
if (hit) {
vec3 p = ro + rd * t;
vec3 n = calcNormal(p);
vec3 alb = vec3(0.78, 0.76, 0.72);
if (mat > 1.5 && mat < 2.5) alb = vec3(0.82, 0.14, 0.12);
else if (mat > 2.5 && mat < 3.5) alb = vec3(0.10, 0.68, 0.76);
else if (mat > 3.5 && mat < 4.5) alb = vec3(0.90, 0.88, 0.84);
else if (mat > 4.5) alb = vec3(0.84, 0.82, 0.77);
// Ceiling area light emitter patch
if (p.y > 0.635 && length(p.xz - lightPos.xz) < 0.22) {
col = vec3(2.8, 2.65, 2.35);
} else {
vec3 toL = lightPos - p;
float dL = length(toL);
vec3 L = toL / max(dL, 1e-4);
float sh = softShadow(p + n * 0.008, L, dL - 0.04);
float ndl = max(dot(n, L), 0.0) * sh / (0.65 + 0.95 * dL * dL);
vec3 direct;
if (!useStylized) {
direct = vec3(1.65, 1.54, 1.38) * ndl;
} else {
float qDirect = stylizedRamp(ndl * 1.25, P_BANDS, P_SOFTNESS);
direct = vec3(1.65, 1.54, 1.38) * qDirect;
}
vec3 bounce = evalBounceCache(p, n, lightPos, useStylized);
col = alb * (direct + bounce);
// Subtle ink contour line on right half around object silhouettes
if (useStylized && mat > 3.5) {
float rim = smoothstep(0.28, 0.12, abs(dot(n, -rd)));
col = mix(col, col * 0.18, rim * 0.72);
}
}
}
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
Stylized nonlinear Monte Carlo rendering defines the look: an artist operator f (a toon ramp, a threshold, a hue shift) applied to outgoing radiance at each path vertex, not only at the pixel. Alone it needs many samples, because f of a noisy estimate is biased. Neural Radiance Caching supplies the missing piece: an MLP that predicts outgoing radiance at any surface point from position, normal, view direction and material. The hop is composite, not an io-type match: training targets are built by applying f to each vertex's estimate, with the tail taken from the cache's own stylized prediction, and render paths stop after one bounce at a cache query whose output is already stylized.
How to build it
Start from an existing NRC implementation (fully fused MLP with hash encoding) inside a DXR or Vulkan path tracer. Keep the training-path logic but insert f at every vertex when accumulating targets: target_k = f(Le_k + throughput × target_k+1), with the last vertex using the cache prediction. Use smooth ramps (smoothstep bands) rather than hard steps, so the fixed point the cache converges to exists and the MLP can represent it. Expose f as a 1D ramp texture per material so artists can paint it. Render paths: primary hit, one stylized direct-light sample, then a cache query. Keep Toon / cel shading with lighting ramps for direct light at the primary hit so terminators stay crisp. Validate against the paper's offline estimator on a few stills before trusting the real-time result.
Field marks
- The self-bootstrapped training loop can oscillate or collapse bands when f has hard steps; stylized transport may have no stable fixed point.
- The MLP's bias toward smooth functions softens band edges in indirect light.
- Applying f per bounce changes energy, so scenes brighten or darken unexpectedly as bounce count changes.
- Needs ray tracing and matrix-core hardware, so there is no web or mobile path.
Prior art
No prior art found on 2026-11-29.
Searches run (4)
- arXiv: all:"neural radiance caching" AND all:"stylized" → 0 results
- GitHub repos: "neural radiance caching" stylized → 0 results
- arXiv: all:"stylized" AND all:"global illumination" AND all:"path tracing" → 0 results
- GitHub repos: stylized "global illumination" "path tracing" → 0 results