Skip to content

bug(rgbw): kRGBWColorimetric* skips source-RGB → LED-XYZ conversion — solver has no target white point #2705

Closed

Description

@zackees

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

Proposed fix

  1. Define an input color space convention (default: sRGB-D65) on DiodeProfile or as a separate parameter to the dispatch.
  2. Apply source_rgb_to_led_absolute_XYZ before the solver — a 3×3 matrix derived from the source primaries + source white, Bradford-adapted to the LED primaries.
  3. Implement the constrained NNLS projection (gist §3) for out-of-hull source targets, used by both solvers and the verifier.
  4. 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).
  5. Update kRgbwDefaultProfile documentation to state the assumed input color space.

References

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions