Repository navigation
study(color): score section 5's two remaining static candidates (#4042) - #4277
Merged
Merged
Conversation
Section 5 has been waiting on a strategy-space definition to compare shaping functions. #4265 removed the need for one: it measured what any *static* strategy could reach, and a single frame cannot beat the best code that frame can emit. So both candidates are evaluated at their best rather than through a particular curve, and the numbers bound the family instead of one member. **Independent RGB gamma is out.** A per-channel transfer applied to the linear drive before quantization -- the honest reading of the name -- is worse than plain rounding at 40 of 40 targets, by at least 2.3x even where rounding does worst: luminance rounding gamma 2.2 2% 0.0605 0.1417 8% 0.0247 0.1734 14% 0.0108 0.1930 Same reason colorBoost went in #4251: a WS2812 drives its diodes with linear PWM, so nothing downstream decodes the curve and the emitted light is the code rather than the drive it came from. A fine appearance control, not a neutral re-encoding. **Value-only shaping over HSV16 survives.** Hue and saturation come from the rounded code and only the value moves, so it is never worse -- 0 of 40 regress -- and every 16-bit value is searched, so this bounds the whole V-only family. At the worst target, 2% luminance: per-channel rounding 0.0605 best value-only shaping 0.0530 static ceiling (#4265) 0.0382 It closes 0.0075 of an available 0.0223: about a third of the room a single frame has. Across the sweep it lands at or below the distance-optimal code's chroma at 36 of 40 targets, and the four exceptions are the distance-versus- chroma disagreement #4265 already recorded rather than a failure here. That leaves linear-light temporal dithering as the only candidate that could close the other two thirds, and it is stateful and waits on the frame cadence P6 wires up. The static half of section 5 is answered. Mutation-tested: a gamma of 1.0 -- an identity transfer -- fails the gamma case, and collapsing the value search to the rounded code's own value fails the headroom case. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9
zackees
added a commit
that referenced
this pull request
Sep 10, 2026
Fair -- "it does not close the last third, it closes almost all of it" only parses if the reader is carrying #4277's framing, where temporal dithering was the candidate that "could close the other two thirds" of what the static ceiling leaves. Read on its own it contradicts itself. Replaced with the numbers, everything measured against the same baseline of per-channel rounding: per-channel rounding 0.0605 -- best value-only shaping 0.0530 12% lower distance-optimal single frame 0.0382 37% lower distance-optimal 8-frame cycle 0.0016 97% lower and the point said plainly: the cycle is not competing for the remainder of a 37% budget, it removes almost all of the error outright. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9
zackees
added a commit
that referenced
this pull request
Sep 10, 2026
… be scored (#4042) (#4280) * study(color): section 5's last candidate does not need the cadence to be scored (#4042) #4277 left linear-light temporal dithering as the remaining candidate, and described it as waiting on the frame cadence P6 wires up. The cadence is needed to *ship* it. It is not needed to score it: an N-frame cycle's time-averaged light is arithmetic, and #4265's static ceiling is the same construction with N = 1. A cycle that spends k of its N frames one code higher averages to a drive of base + k/N, per channel, so the reachable averages are a grid. Averaging is done in linear XYZ rather than in OKLab, because light averages and perceptual coordinates do not -- the same assumption `pixel_controller.h`'s dither guide makes when it says the eye integrates the cycle above ~50 Hz. Worst case over the same 40 targets: per-channel rounding 0.0605 static ceiling 0.0466 temporal, 2 frames 0.0304 temporal, 4 frames 0.0109 temporal, 8 frames 0.0086 The static worst is at a different target from the 2% one #4265 quotes, which is why it reads 0.0466 rather than 0.0382: at 1% luminance no single frame improves on rounding at all. At the 2% target -- rounding 0.0605, best single frame 0.0382 -- eight frames reach **0.0016**. The remaining candidate is not in the same class as the static ones. It does not close the last third; it closes almost all of it. Eight frames is also the cycle `BINARY_DITHER` already runs, so the cadence question is not a new one. Three things this does not say, all in the doc rather than implied. It is a ceiling, like the static one. It says nothing about flicker -- a cycle that reaches the floor by toggling the bottom codes is exactly the trade #4156 R8 asks to have declared. And it assumes a pipeline dither that can choose sub-code average drives, a different mechanism from `BINARY_DITHER`, which is gated on a nonzero source. The control is the load-bearing part: at one frame the grid collapses to the integer codes, so the result must be an ordinary static answer. Without it the whole measurement could be an artefact of the search. Nesting is checked too -- every k/2 is a k/4 is a k/8, so a longer cycle cannot lose. Mutation-tested: collapsing the sub-code step to a whole code, and scoring the worst target at one frame instead of eight, each fail. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9 * review(color): name the metric, and give the control the static domain Two findings, and the second is a conflation this very file records having made once already. **The helper was named after a quantity it does not compute.** `bestTemporalChroma` selected by minimum OKLab distance and returned that candidate's chroma, while calling itself "best chroma reachable" -- exactly the distance-versus-chroma slip #4265 documents three sections up in the same document. Renamed `distanceOptimalCycleChroma`, and the doc says what is tabulated. Distance is still the right objective, and the reason is now stated instead of assumed: minimising chroma on its own is degenerate. A cycle drives chroma to zero by going to black, so an unconstrained chroma minimum answers "emit nothing" at every target. What a strategy picks is the closest reproduction, and the table reports what that costs on the axis. **The one-frame control searched a different domain from the thing it controlled.** Base offsets ran -1..1 with `step/N` in [0, 1], covering [-1, 2], while the static search covers [-2, 2] -- so the case could only assert a lower bound, not the equivalence it claimed. Base offsets now run -2..1, which covers [-2, 2] for every cycle length, and the case compares the one-frame result against a static reference computed beside it, to within a float ULP. No number moves: worst case over the 40 targets is still 0.0605 rounding, 0.0466 static, 0.0304 / 0.0109 / 0.0086 at two, four and eight frames, and 0.0016 at the 2% target. Recorded rather than dressed up: narrowing the window back to -1..1 fails nothing, because no target in the sweep has a static optimum at a -2 offset. The widening is the control's argument, not a measurement -- a control whose domain merely happens to suffice is one nobody can check. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9 * review(color): state the eight-frame comparison against one baseline Fair -- "it does not close the last third, it closes almost all of it" only parses if the reader is carrying #4277's framing, where temporal dithering was the candidate that "could close the other two thirds" of what the static ceiling leaves. Read on its own it contradicts itself. Replaced with the numbers, everything measured against the same baseline of per-channel rounding: per-channel rounding 0.0605 -- best value-only shaping 0.0530 12% lower distance-optimal single frame 0.0382 37% lower distance-optimal 8-frame cycle 0.0016 97% lower and the point said plainly: the cycle is not competing for the remainder of a 37% budget, it removes almost all of the error outright. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9 --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.
Refs #4042 (P8, section 5).
Section 5 has been waiting on a strategy-space definition before it could compare shaping functions:
#4265 removed the need for one. It measured what any static strategy could reach, and a single frame cannot beat the best code that frame can emit. So both candidates are evaluated at their best rather than through a particular curve, and the numbers bound the family instead of one member's score.
Independent RGB gamma is out
A per-channel transfer applied to the linear drive before quantization — the honest reading of the name. Worse than plain rounding at 40 of 40 targets, by at least 2.3× even where rounding does worst:
The reason is the one that removed
colorBoostin #4251: a WS2812 drives its diodes with linear PWM, so nothing downstream decodes the curve, and the emitted light is the code rather than the drive the code came from. Gamma is a fine appearance control and is not a neutral re-encoding.Value-only shaping over HSV16 survives, and takes about a third
Hue and saturation come from the rounded code and only the value moves, so it is never worse than per-channel rounding — 0 of 40 regress. Every 16-bit value is searched, so this bounds what any V-only shaping function could do.
At the worst target, 2% luminance:
It closes 0.0075 of an available 0.0223 — about a third of the room a single frame has.
Across the sweep it lands at or below the distance-optimal code's chroma at 36 of 40 targets. The four exceptions are the distance-versus-chroma disagreement #4265 already recorded — the search minimises OKLab distance, which includes lightness — not a failure of the strategy.
What that leaves
Linear-light temporal dithering, the only remaining candidate that could close the other two thirds, and which is stateful and waits on the frame cadence P6 wires up. The static half of section 5 is answered: one candidate out, one that survives and is worth having, and neither reaches the ceiling.
Verification
bash test --cpp— 299/299 unit, 84/84 examplesbash lint— 0 errors🤖 Generated with Claude Code
https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9