Skip to content

bug(rgbw): kRGBWColorimetricBoosted (wx_lp_legacy) produces identical output to kRGBWColorimetric (strict sub-gamut) #2706

Closed

Description

@zackees

Summary

solve_wx_lp and solve_strict_subgamut (added in #2545) return bit-identical RGBW tuples for the same input. The gist §9 description ("Same color accuracy as strict, brighter for in-gamut targets") is not realized — wx_lp_legacy never reaches a 4-channel-active output even on full saturated white.

Observation

Sweeping inputs through both modes with the default profile yields RGBW outputs that match channel-for-channel, including the case where the spec promises a 4-channel-active result (saturated white at D65). This was raised by the verifier author against the implementation in https://gist.github.com/JChalka/999c68f83299dbb842e31f836a4c4cbc.

Root cause

The two solvers identify the same vertex of the same feasible polytope.

For any target X_t, the polytope is a 1-parameter family in w:
```
{ (r', g', b', w) >= 0 : r'·P_R + g'·P_G + b'·P_B + w·P_W = X_t }
```
with the unique relation [r'; g'; b'] = a − w·d where a = P_RGB_inv · X_t and d = P_RGB_inv · P_W. (When X_t was built from the input RGB drive values, a = (s_r, s_g, s_b) exactly — see rgbw_colorimetric.cpp.hpp:67 and :178-189.)

  • solve_wx_lp (rgbw_colorimetric.cpp.hpp:176-207) picks the W-maximizing vertex via the binding constraint min(a[i]/d[i]). Exactly one of {r', g', b'} is driven to zero.
  • solve_strict_subgamut (rgbw_colorimetric.cpp.hpp:70-127) picks the same vertex via barycentric routing of the target xy through {RGW, RBW, BGW}, then solves the 3×3 system with the omitted channel forced to zero.

The two criteria identify the same active constraint set for every in-gamut target. The remaining 3-channel solve gives identical numbers. There is no input — short of out-of-hull cases that hit the differing post-clamp / normalization paths — where the two implementations can disagree.

The only normalization difference is that solve_wx_lp divides by max(t[0..3]) including W (line 198) while solve_strict_subgamut divides by max(t[0..2]) over the 3 nonzero channels (line 116). On full-saturation white both max values clamp to 1.0, so the normalize step is a no-op.

Why this wasn't caught in tests

tests/fl/gfx/rgbw_colorimetric.cpp exercises the public dispatch and the inline math primitives, but the direct-solver comparison (solve_strict_subgamut vs solve_wx_lp on the same input) is deferred to a FASTLED_RGBW_COLORIMETRIC=1 build target and isn't run in CI:

Direct solver correctness (strict_subgamut, wx_lp, build_lut, solve_rgbcct) requires the library to be built with FASTLED_RGBW_COLORIMETRIC=1, which the default test build does not do — so those validations are deferred to a dedicated build target or run manually by the developer.

Proposed fix

  1. Reconcile with the math-model gist §9 (https://gist.github.com/JChalka/915603d7930b7216d5c5aae834ec2ea9):
    • If the spec's wx_lp_legacy is genuinely just max W s.t. residual ≥ 0 (as the FastLED implementation transcribes), the "brighter for in-gamut targets" claim in the parent issue feat(rgbw): sub-gamut white-extraction algorithm for chromaticity-accurate RGBW output #2545 is wrong, and the two modes should be either merged or differentiated by some other policy (e.g. wx_radial_virtual from gist §8 or wx_virtual_axis_maxbright from §10).
    • If the spec intends a 4-channel-active result on white (W overdrive past the strict-sub-gamut vertex), the LP objective needs to change — e.g. set W from a target W-intent and project residuals into the non-negative orthant without forcing any channel to zero, accepting a chromaticity excursion.
  2. Add a direct-comparison regression test in a FASTLED_RGBW_COLORIMETRIC=1-enabled target that constructs an input where strict and LP MUST diverge per the spec, and asserts non-equality.
  3. If the current solve_wx_lp is the spec-correct wx_lp_legacy, replace kRGBWColorimetricBoosted with one of wx_radial_virtual / wx_virtual_axis_maxbright so users actually get the brighter-output mode promised by the enum name.

Dependency

Blocked-by / interleaved with #2705 (missing source→LED-XYZ conversion). Until target white is correctly set, the LP vs sub-gamut divergence is hard to verify against any external reference — but the equivalence demonstrated here is independent of the source-space defect and will persist after #2705 is fixed.

References

Activity

  1. moved this from Triage to Done in FastLED Trackeron Jun 3, 2026
  2. added a commit that references this issue on Jun 3, 2026
    6cd4a07
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