Skip to content

P5.s6: exact Airy thin film per wavelength in the spectral mode - #115

Open
DennisSmolek wants to merge 1 commit into
mainfrom
issue-55-spectral-thin-film
Open

DennisSmolek wants to merge 1 commit into
mainfrom
issue-55-spectral-thin-film

Conversation

@DennisSmolek

Copy link
Copy Markdown
Member

Part of #55 (P5.s6, DIVERGES V570; V257 superseded).

What changed

  • ptThinFilmWgsl(spectral) (packages/pathtracer/src/bsdf/thinfilm-wgsl.ts): with integrator.spectral + features.thinFilm the film Fresnel is the exact unpolarised Airy sum per wavelength lane (the formula of bench/metrics/thinfilm-airy.ts: complex Fresnel amplitudes at both interfaces, s and p, the lane's complex base IOR). A metal's base is p.eta + i p.k (the RGB-uplifted colour at that wavelength, as before); a dielectric's is its scalar IOR. No thickness fade. The call site is ptShadingModulesWgsl (megakernel and wavefront share it).
  • Every other kernel is byte-identical: node bench/size-snapshot.ts before/after, diff -rq empty over all 355 files. New variant spectral-pbr-albedo-thinFilm (58.0 KB minified megakernel, over the ~50 KB DXC class).
  • lobe-oracle gets spectral=1; wf-p5-check gets the case film-spheres; a WGSL-text unit test.

Verification (M5 Pro, --no-lock, best effort, not timings)

node bench/runner/run.ts --page lobe-oracle --args fuzz=0 film=1 spectral=1 (and spectral=0), 256 spp, against the exact spectral Airy sum under D65. Max absolute error, near-normal bins (mu_o > 0.55), RGB fit vs spectral:

case RGB spectral
dielectric d 0.15-1.0 1.2-2.5e-3 2-3e-4
dielectric, film n 1.8 1.2e-2 3e-4
grey metal d 0.2 / 0.5 2.4e-2 / 3.3e-2 1e-4 / 3e-4
rough dielectric 2.4e-3 3e-4

The worst bin over all angles in spectral mode is 9e-3 (smooth dielectric, sphere rim, noise).
--page wf-p5-check --args cases=film-spheres,cornell variants=plain,inline,sorted spp=16: megakernel vs wavefront per pixel 6.9e-7 (film-spheres), 9.0e-7 (Cornell), 0 non-finite. pnpm typecheck shows only the known @pmndrs/vdb errors; thinfilm.test.ts, integrator-wgsl.test.ts, spectral tests pass.

Left open

The optional dispersive coat / layered interface (V256) is not done. A conductor's eta and k still come from the RGB-uplifted colour (no measured spectra). No edit near ptSpecIor (PR #79).

🤖 Generated with Claude Code

With integrator.spectral and a thin-film material the film Fresnel is the exact
unpolarised Airy sum per wavelength lane instead of the Belcour-Barla RGB fit.
Other kernels are byte-identical. lobe-oracle gains spectral=1; wf-p5-check gains film-spheres.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant