Repository navigation
Keep the sign of the spectral weight so dispersion fringes match Cycles (#50) - #53
Merged
Merged
Conversation
…es' saturation (#50) The weight of a hero wavelength was its linear sRGB clamped at zero, and every sample was clamped again when it reached the film. Spectral colours lie outside the sRGB gamut, so the negative lobes were dropped and the fringes drifted toward white (0.67x of Cycles on the prism view). The weight now keeps its sign and is divided by the signed mean, and a dispersive scene accumulates negative channels like Cycles does. A scene without dispersion compiles the old sanitising and renders bit for bit as before.
3 tasks
This was referenced Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #50
Spectral colours lie outside the sRGB gamut, so the linear sRGB weight of one wavelength has negative lobes. Cook clamped the weight at zero, then clamped every sample again before the film, which dropped the lobes and pulled the fringes toward white. Cycles keeps them signed (its raw output has negative pixels). Now the weight keeps its sign and is divided by its signed mean over 400 to 700 nm, and a scene with dispersion accumulates negative channels. A scene without dispersion compiles the old sanitising.
Evidence
RTX 3060, 256 spp, Cook against Cycles 5.3 on the same scenes (
tools/dispersion-parity*).The gem at 256 spp is noisy (mean 0.014, a few bright pixels): at 1024 spp both renderers agree within 4 percent on fringe colour and the red to blue spread is -12.4 against -12.9 px. Other things tried on the prism view: widening the range to 380-780 nm changes nothing (0.668); signed weights with the per-sample clamp kept raise the fringe to 0.81 but the mean to 1.06 (gem red 1.43).
Cook on the left, Cycles on the right (before, then after):
Dispersion 0 is bit-identical: sha256 of the 256 spp raw render before and after is 40c14f86823b0468 for prism-view and 631b2734795f42e5 for gem (first 16 hex digits, same for both builds).
The image can now hold small negative values at the most saturated fringes (3 percent of the pixels in the Cycles prism-view render do too); the README says so, and an encoder clamps them.
How I checked it
node tools/dispersion-parity.mjs,tools/dispersion-parity-cycles.py(Blender 5.3) andtools/dispersion-parity-compare.pyon prism-view and gem, before and after.node --test: 182 pass.node tools/run-cargo-tests.mjs: 137 and 23 pass. Two kernel-text tests fail on a Windows checkout with CRLF line endings, with or without this change, and pass with LF.SCENE_HAS_DISPERSION.release-guardprints clean.