Repository navigation
Description
Summary
Both kRGBWColorimetric and kRGBWColorimetricBoosted (added in #2545) interpret the input RGB byte triple as native-emitter drive coordinates rather than as a named source color space. There is no source_rgb_to_led_absolute_XYZ step, so the solver's effective "target white" for RGB=(255,255,255) is wherever the native gamut sum lands — not D65, not even the profile's nominal xy_w.
This makes the implementation impossible to verify against the math-model gist's reference results (e.g. Sonia's measured D65 case in #2545) and produces visibly wrong chromaticity on white.
Reproduction
For the default kRgbwDefaultProfile (SK6812 RGBW3535, lum ratios R=0.10, G=0.37, B=0.08), RGB = (255,255,255):
- Expected (gist §5, with sRGB-D65 source): target xy ≈ (0.3127, 0.3290), W diode drives most of the output.
- Actual: target xy ≈ (0.20, 0.23) — heavily blue-shifted because B has a very large Z component in xyY→XYZ, and the solver treats the input as full-drive on the native primaries.
Root cause
src/fl/gfx/rgbw_colorimetric.cpp.hpp:76-78 (and the _xy variant at :136-137):
```cpp
X_t[0] = cache.P_R[0]*s_r + cache.P_G[0]*s_g + cache.P_B[0]*s_b;
X_t[1] = cache.P_R[1]*s_r + cache.P_G[1]*s_g + cache.P_B[1]*s_b;
X_t[2] = cache.P_R[2]*s_r + cache.P_G[2]*s_g + cache.P_B[2]*s_b;
```
This is the LED-side basis projection — the inverse of what the spec calls for. Per the parent issue #2545 / gist §5:
```
X_t = source_rgb_to_led_absolute_XYZ(source_rgb) ← missing
xy_t = XYZ_to_xy(X_t)
```
The spec also requires (gist §3) out-of-hull NNLS projection when the named source gamut (Rec709 / Rec2020 / sRGB-D65) reaches beyond the LED hull; this is also absent. The parent issue calls this a correctness requirement, not a style choice: "Builder and verifier must use the same projection."
w_color_temperature only shifts the W vertex of the simplex (rgbw.cpp.hpp:213-217, rgbw_colorimetric.cpp.hpp:25-28). It is NOT a target-white parameter.
Impact
kRGBWColorimetricproduces native-gamut output, not chromaticity-accurate output relative to any standard color space.kRGBWColorimetricBoostedshares the same input path and suffers the same defect.- D65-based verifiers (Sonia's spreadsheet, the test gist at https://gist.github.com/JChalka/999c68f83299dbb842e31f836a4c4cbc) cannot match the implementation regardless of profile tuning.
- The two solvers also collapse to identical outputs as a downstream symptom — see companion issue.
Proposed fix
- Define an input color space convention (default: sRGB-D65) on
DiodeProfileor as a separate parameter to the dispatch. - Apply
source_rgb_to_led_absolute_XYZbefore the solver — a 3×3 matrix derived from the source primaries + source white, Bradford-adapted to the LED primaries. - Implement the constrained NNLS projection (gist §3) for out-of-hull source targets, used by both solvers and the verifier.
- Add a regression test:
RGB=(255,255,255)with sRGB-D65 source must produce RGBW whose reconstructed chromaticity matches D65 within the LED hull (or its NNLS projection). - Update
kRgbwDefaultProfiledocumentation to state the assumed input color space.
References
- Parent issue: feat(rgbw): sub-gamut white-extraction algorithm for chromaticity-accurate RGBW output #2545
- Math model: https://gist.github.com/JChalka/915603d7930b7216d5c5aae834ec2ea9 (§3, §5)
- Verifier sketch: https://gist.github.com/JChalka/999c68f83299dbb842e31f836a4c4cbc
- User-supplied spreadsheet (D65 verification): https://docs.google.com/spreadsheets/d/1wx-IJPwV0-AA_2PoBDYdnHenge4dAe2T-m35GPDpcbI/edit
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(rgbw): source RGB color space + differentiated boosted solver + H…
fix(rgbw): default source = native LED gamut + D65; named-gamut opt-in (
fix(color): refuse a declared source space that cannot be built (#4156 …