Spectral upsampling with sigmoid polynomials × Film emulation (spectral stock simulation)
Film stocks exposed by spectra. Expose CG renders onto simulated film stocks from spectral radiance instead of RGB, so colour crosstalk and the look of saturated lights come from the stock's layer sensitivities, not from a guess at the spectrum made after rendering.
Open in StudioReproduced14.8× · 0.460 ms
Verified proof

Split-screen WebGL2 proof comparing standard RGB shading plus RGB matrix film grading (left, clipping narrow-band neon tubes and banding a dispersed prism beam into flat primaries) against 16-band Jakob-Hanika sigmoid-polynomial spectral upsampling integrated directly against 3-layer silver-halide spectral sensitivities, H&D dye curves, and red-layer halation (right).
Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · reproduces natural film emulsion crosstalk, smooth prism dispersion continuity, and organic red-layer halation on narrow-band emitters across 16 spectral bands (400-700nm)
Show GLSL proof (182 lines)
const float FILM_EXPOSURE = 1.18; // P
const float DYE_CONTRAST = 1.38; // P
const float HALATION_GAIN = 0.68; // P
const float PRINT_WARMTH = 0.24; // P
float gauss(float x, float mu, float sig) {
float d = (x - mu) / sig;
return exp(-0.5 * d * d);
}
// Jakob & Hanika (2019) sigmoid-polynomial spectral upsampling basis evaluated at wavelength nm in [400, 700]
float sigmoidUpsample(vec3 rgb, float nm) {
vec3 c = clamp(rgb, 0.004, 0.996);
float u = (nm - 550.0) / 150.0;
vec3 lo = log(c / (1.0 - c));
float c2 = lo.g;
float c1 = (lo.r - lo.b) / 1.20;
float c0 = (lo.r + lo.b - 2.0 * lo.g) / 0.72;
float x = c0 * u * u + c1 * u + c2;
return 0.5 + 0.5 * x / sqrt(1.0 + x * x);
}
vec3 cieXYZ(float nm) {
float x1 = (nm - 442.0) * (nm < 442.0 ? 0.0624 : 0.0374);
float x2 = (nm - 599.8) * (nm < 599.8 ? 0.0264 : 0.0323);
float x3 = (nm - 501.1) * (nm < 501.1 ? 0.0490 : 0.0382);
float X = 0.362 * exp(-0.5 * x1 * x1) + 1.056 * exp(-0.5 * x2 * x2) - 0.065 * exp(-0.5 * x3 * x3);
float y1 = (nm - 568.8) * (nm < 568.8 ? 0.0213 : 0.0247);
float y2 = (nm - 530.9) * (nm < 530.9 ? 0.0613 : 0.0322);
float Y = 0.821 * exp(-0.5 * y1 * y1) + 0.286 * exp(-0.5 * y2 * y2);
float z1 = (nm - 437.0) * (nm < 437.0 ? 0.0845 : 0.0278);
float z2 = (nm - 459.0) * (nm < 459.0 ? 0.0385 : 0.0725);
float Z = 1.217 * exp(-0.5 * z1 * z1) + 0.681 * exp(-0.5 * z2 * z2);
return max(vec3(X, Y, Z), 0.0);
}
vec3 xyzToLinSrgb(vec3 xyz) {
return vec3(
3.2406 * xyz.x - 1.5372 * xyz.y - 0.4986 * xyz.z,
-0.9689 * xyz.x + 1.8758 * xyz.y + 0.0415 * xyz.z,
0.0557 * xyz.x - 0.2040 * xyz.y + 1.0570 * xyz.z
);
}
// 3-layer color negative film spectral sensitivities (Kodak Vision3-inspired overlapping AgX emulsion curves)
vec3 filmSensitivity(float nm) {
float sR = 1.00 * gauss(nm, 646.0, 29.0) + 0.14 * gauss(nm, 595.0, 22.0);
float sG = 0.96 * gauss(nm, 548.0, 32.0) + 0.12 * gauss(nm, 495.0, 24.0);
float sB = 1.02 * gauss(nm, 444.0, 27.0) + 0.08 * gauss(nm, 485.0, 18.0);
return vec3(sR, sG, sB);
}
void evalStudio(vec2 uv, out int kind, out vec3 alb, out float shade, out float prismNm, out float prismGlow, out vec3 rodDist, out float specAmt) {
vec3 ro = vec3(0.0, 0.15, 2.45);
vec3 rd = normalize(vec3(uv.x, uv.y - 0.04, -1.65));
vec3 L = normalize(vec3(0.58, 0.78, 0.52));
kind = 0;
alb = vec3(0.03, 0.035, 0.045);
shade = 0.28;
prismNm = 550.0;
prismGlow = 0.0;
specAmt = 0.0;
float bandY = uv.y - 0.25 - 0.055 * sin(uv.x * 2.4 + iTime * 0.35);
float bandMask = exp(-pow(bandY / 0.082, 2.0)) * smoothstep(0.49, 0.40, abs(uv.x));
float sx = abs(uv.x) / 0.46;
prismNm = mix(412.0, 688.0, clamp(sx, 0.0, 1.0));
prismGlow = bandMask * 4.2;
float rx = abs(uv.x);
float dCyan = length(vec2(rx - 0.38, max(abs(uv.y - 0.01) - 0.12, 0.0)));
float dAmber = length(vec2(rx - 0.25, max(abs(uv.y - 0.01) - 0.12, 0.0)));
float dRuby = length(vec2(rx - 0.12, max(abs(uv.y - 0.01) - 0.12, 0.0)));
rodDist = vec3(dCyan, dAmber, dRuby);
float minT = 10.0;
if (rd.y < -0.01) {
float tf = (-0.34 - ro.y) / rd.y;
if (tf > 0.0 && tf < minT) {
vec3 fp = ro + rd * tf;
if (fp.z > -2.6) {
minT = tf;
kind = 1;
alb = vec3(0.035, 0.038, 0.044);
shade = 0.26 + 0.40 * exp(-abs(fp.z) * 0.4);
specAmt = 0.26 * exp(-abs(fp.z + 0.3) * 0.8);
}
}
}
vec3 sc[4]; vec3 salb[4];
sc[0] = vec3(-0.34, -0.17, 0.18); salb[0] = vec3(0.18, 0.56, 0.15);
sc[1] = vec3(-0.13, -0.17, 0.26); salb[1] = vec3(0.84, 0.54, 0.40);
sc[2] = vec3( 0.13, -0.17, 0.26); salb[2] = vec3(0.84, 0.54, 0.40);
sc[3] = vec3( 0.34, -0.17, 0.18); salb[3] = vec3(0.18, 0.56, 0.15);
for (int i = 0; i < 4; i++) {
vec3 oc = ro - sc[i];
float b = dot(oc, rd);
float disc = b * b - (dot(oc, oc) - 0.155 * 0.155);
if (disc > 0.0) {
float ts = -b - sqrt(disc);
if (ts > 0.0 && ts < minT) {
minT = ts;
kind = 2;
vec3 hp = ro + rd * ts;
vec3 n = normalize(hp - sc[i]);
float ndl = max(dot(n, L), 0.0);
float rim = pow(1.0 - max(dot(n, -rd), 0.0), 3.0);
alb = salb[i];
shade = 0.10 + 1.32 * ndl + 0.20 * rim;
specAmt = pow(max(dot(reflect(-L, n), -rd), 0.0), 24.0) * 0.58;
}
}
}
if (min(min(dCyan, dAmber), dRuby) < 0.015) kind = 3;
}
float sceneSpectralRadiance(float nm, int kind, vec3 alb, float shade, float prismNm, float prismGlow, vec3 rodDist, float specAmt) {
float illum = 0.65 + 0.72 * smoothstep(400.0, 680.0, nm);
float eCyan = exp(-rodDist.x * 36.0) * (rodDist.x < 0.015 ? 9.8 : 1.55) * gauss(nm, 486.0, 14.0);
float eAmber = exp(-rodDist.y * 36.0) * (rodDist.y < 0.015 ? 10.8 : 1.65) * gauss(nm, 589.0, 13.0);
float eRuby = exp(-rodDist.z * 36.0) * (rodDist.z < 0.015 ? 10.2 : 1.60) * (0.85 * gauss(nm, 648.0, 15.0) + 0.42 * gauss(nm, 442.0, 16.0));
float rods = eCyan + eAmber + eRuby;
float prism = prismGlow * gauss(nm, prismNm, 15.0);
if (kind == 3) return rods * 1.35;
float refl = sigmoidUpsample(alb, nm);
float surf = refl * illum * shade + specAmt * illum;
float spill = (kind == 1 ? 0.55 : 0.24) * (exp(-rodDist.x * 7.5) * gauss(nm, 486.0, 18.0) + exp(-rodDist.y * 7.5) * gauss(nm, 589.0, 16.0) + exp(-rodDist.z * 7.5) * gauss(nm, 648.0, 18.0));
return surf + (kind == 0 ? prism : 0.0) + rods * 0.42 + spill * (0.35 + 0.65 * refl);
}
vec3 filmDensityCurve(vec3 exposure) {
vec3 logE = log(max(exposure * FILM_EXPOSURE, vec3(1e-4))) / 2.302585;
vec3 gamma = vec3(1.56, 1.50, 1.44) * DYE_CONTRAST;
vec3 mid = vec3(-0.22, -0.20, -0.18);
return 0.04 + 2.55 / (1.0 + exp(-gamma * (logE - mid)));
}
vec3 printFromDensities(vec3 d) {
mat3 dyeXtalk = mat3(
1.00, 0.14, 0.04,
0.10, 1.00, 0.16,
0.03, 0.11, 1.00
);
vec3 effD = dyeXtalk * max(d - vec3(0.16), vec3(0.0));
vec3 printLin = pow(vec3(10.0), -effD * 0.52);
printLin *= vec3(1.0 + 0.22 * PRINT_WARMTH, 1.0 + 0.04 * PRINT_WARMTH, 1.0 - 0.18 * PRINT_WARMTH);
return clamp(1.0 - printLin, 0.0, 1.0);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
int kind; vec3 alb; float shade; float prismNm; float prismGlow; vec3 rodDist; float specAmt;
evalStudio(uv, kind, alb, shade, prismNm, prismGlow, rodDist, specAmt);
bool useSpectralFilm = uv.x > 0.0;
vec3 col = vec3(0.0);
if (!useSpectralFilm) {
vec3 illumRgb = vec3(1.18, 0.96, 0.78);
vec3 surf = alb * illumRgb * shade + vec3(specAmt) * illumRgb;
float t = clamp((prismNm - 412.0) / 276.0, 0.0, 1.0);
vec3 prismRgb = clamp(vec3(abs(t * 6.0 - 3.0) - 1.0, 2.0 - abs(t * 6.0 - 2.0), 2.0 - abs(t * 6.0 - 4.0)), 0.0, 1.0);
vec3 rodsRgb = vec3(0.0, 0.95, 1.0) * exp(-rodDist.x * 36.0) * (rodDist.x < 0.015 ? 9.8 : 1.55)
+ vec3(1.0, 0.72, 0.0) * exp(-rodDist.y * 36.0) * (rodDist.y < 0.015 ? 10.8 : 1.65)
+ vec3(1.0, 0.05, 0.45) * exp(-rodDist.z * 36.0) * (rodDist.z < 0.015 ? 10.2 : 1.60);
vec3 spillRgb = (kind == 1 ? 0.55 : 0.24) * (vec3(0.0, 0.9, 1.0) * exp(-rodDist.x * 7.5) + vec3(1.0, 0.7, 0.0) * exp(-rodDist.y * 7.5) + vec3(1.0, 0.1, 0.4) * exp(-rodDist.z * 7.5));
vec3 hdr = (kind == 3) ? rodsRgb * 1.35 : (surf + (kind == 0 ? prismRgb * prismGlow * 0.88 : vec3(0.0)) + rodsRgb * 0.42 + spillRgb * (0.35 + 0.65 * alb));
hdr *= FILM_EXPOSURE;
col = clamp((hdr * (1.85 * hdr + 0.05)) / (hdr * (1.80 * hdr + 0.72) + 0.14), 0.0, 1.0);
col = pow(col, vec3(0.95 + 0.14 * DYE_CONTRAST));
} else {
const int BANDS = 16;
vec3 filmExp = vec3(0.0);
vec3 xyzCheck = vec3(0.0);
for (int i = 0; i < BANDS; i++) {
float nm = 405.0 + (float(i) + 0.5) * (290.0 / float(BANDS));
float L = sceneSpectralRadiance(nm, kind, alb, shade, prismNm, prismGlow, rodDist, specAmt);
filmExp += L * filmSensitivity(nm);
xyzCheck += L * cieXYZ(nm);
}
filmExp *= (290.0 / float(BANDS)) * 0.0115;
float halR = (exp(-rodDist.x * 8.5) * 0.35 + exp(-rodDist.y * 8.0) * 1.05 + exp(-rodDist.z * 7.5) * 1.25) * HALATION_GAIN;
float halPrism = prismGlow * 0.11 * HALATION_GAIN * smoothstep(500.0, 660.0, prismNm);
filmExp.r += (halR + halPrism) * 0.88;
filmExp.g += (halR + halPrism) * 0.16;
vec3 dens = filmDensityCurve(filmExp);
vec3 filmPos = printFromDensities(dens);
vec3 cieLin = max(xyzToLinSrgb(xyzCheck * (290.0 / float(BANDS)) * 0.0085), 0.0);
float hiDesat = smoothstep(1.2, 4.5, max(filmExp.r, max(filmExp.g, filmExp.b)));
col = mix(filmPos, mix(filmPos, vec3(0.99, 0.96, 0.91), 0.55), hiDesat * 0.65);
col = mix(col, clamp(cieLin / (1.0 + cieLin), 0.0, 1.0), 0.10);
float grain = fract(sin(dot(fragCoord.xy + floor(iTime * 12.0), vec2(12.9898, 78.233))) * 43758.5453) - 0.5;
col = clamp(col + grain * 0.022, 0.0, 1.0);
}
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
Spectral upsampling with sigmoid polynomials turns RGB textures into smooth reflectance spectra so a spectral renderer can output radiance per wavelength. Film emulation (spectral stock simulation) normally starts from an hdr-image and expands RGB to a spectrum itself; the hop is composite because radiance is not its input type. The renderer's multispectral output replaces that expansion step: each film layer's exposure becomes the integral of the spectral image against that layer's sensitivity curve, and density curves, dye overlap and the print stage then run unchanged.
How to build it
Render in a spectral path tracer that already uses sigmoid-polynomial upsampling for textures (Mitsuba 3's spectral variants do), writing a multispectral EXR with a modest number of bands. Give light sources real emission spectra rather than upsampled RGB. Modify an open spectral film emulator in Python so its exposure stage reads the band image directly, resampling the stock's sensitivity data to the band centres. Compare against the same scene rendered in RGB and emulated the usual way, paying attention to saturated LEDs, foliage and skin, where the two paths should differ most.
Field marks
- Most emulator tooling expects RGB and needs changes to accept spectra.
- Band count drives file size and memory.
- Wrong light spectra affect the result more than the film model does.
- Accuracy is limited by the quality of the measured stock data.
Prior art
No prior art found on 2026-11-29.
Searches run (4)
- arXiv: all:"spectral rendering" AND all:"film emulation" → 0 results
- GitHub repos: "spectral rendering" "film emulation" → 0 results
- arXiv: all:"film simulation" AND all:"spectral sensitivity" → 0 results
- GitHub repos: "film simulation" "spectral sensitivity" → 0 results