Skip to content

feat(colorimetric): split shared response layer and design RGB solve entrypoint #3242

Closed

Description

@zackees

Context

The follow-up discussion in #2748 identified a broader design problem beyond the immediate RGBW endpoint-scaling fixes: the reusable colorimetric solver pieces are currently tied to rgbw_colorimetric, and there is no explicit RGB-only entrypoint that guarantees the solve runs after correction/temperature/brightness/gamma decisions but before chipset output.

#3231 tracks this together with RGBW endpoint-scaling follow-ups. This issue splits out the shared solver/refactor and RGB entrypoint design so it can be planned independently of the remaining RGBW verifier work.

Problem

The current RGBW path already performs its colorimetric conversion late in the pixel load path, using the premixed color adjustment values. That is the right shape for RGBW because the solver sees adjusted source values before bytes are emitted.

For an RGB-only colorimetric path, the same ordering requirement matters:

input CRGB
  -> correction / temperature / brightness / gamma policy
  -> colorimetric RGB solve
  -> chipset output bytes

Once a colorimetric solve produces final RGB channel values, later per-channel correction, temperature, brightness, or gamma mutation can invalidate the solved chromaticity. The integration point therefore needs to make post-solve mutation impossible or very explicit.

Proposal

Add a shared colorimetric_response layer for portable colorimetric primitives, then add an opt-in RGB colorimetric dispatch path at the final pixel load boundary.

Suggested implementation shape:

  • Extract reusable math/profile helpers from src/fl/gfx/rgbw_colorimetric.* into src/fl/gfx/colorimetric_response.*.
  • Keep RGBW-specific topology, W extraction, boosted mode, and RGBCCT logic in rgbw_colorimetric.*.
  • Add an RGB-only colorimetric config/API separate from the existing RGBW/RGBWW white-channel config.
  • Integrate RGB colorimetric solving near the existing RGB pixel load/scale path, not inside each chipset driver.
  • Ensure solved RGB bytes are emitted directly without a second correction/brightness/temperature pass.

Acceptance criteria

  • Shared helper extraction causes no intentional RGBW output changes.
  • Existing RGBW tests continue to pass after the extraction.
  • New tests cover the shared colorimetric_response primitives independently of RGBW topology.
  • An opt-in RGB colorimetric mode has a clear API/config path and does not affect default RGB output.
  • The RGB colorimetric solve runs after final source-value policy decisions and before chipset byte emission.
  • Tests or a mock output path prove that no post-solve per-channel scaling/correction is applied.
  • The design remains compile-time gated or otherwise MCU-friendly so boards that do not use colorimetric solving do not pay unnecessary binary-size cost.

Open questions

  • Should the RGB-only mode share the existing FASTLED_RGBW_COLORIMETRIC gate initially, or get a dedicated FASTLED_RGB_COLORIMETRIC gate?
  • Should gamma/power policy be folded into the same pre-solve adjustment path, or should the RGB colorimetric entrypoint explicitly accept already-final linear/source values?
  • What public API shape should expose the RGB source gamut and measured emitter profile without overloading the existing white-channel config?

Related issues

Activity

  1. zackees commented on Jun 18, 2026

    @zackees
    MemberAuthor

    ⚠ /clud-fix intake gate failed. This comment is the deliverable, not a merged PR. If a session /goal hook references this issue URL, run /goal clear after reading — it will NOT auto-satisfy.

    Why the gate failed

    /clud-fix is structured around a falsifiable reproduction: implement, merge, then re-run the reporter's reproduction case against merged main. This issue is a forward-looking design + refactor with three explicit "Open questions" that the issue itself flags as undecided. There is:

    • no reproduction case to validate against,
    • no falsifiable bug symptom (the RGBW path described already works — the ask is to add an RGB analogue),
    • broad scope (extract shared module + new public API + new pixel-load integration + tests + binary-size gate).

    So this run produces a planned-fix report instead of a PR. Once the open questions below are decided by the maintainer, a normal /clud-pr invocation can land the implementation in well-bounded chunks.

    What the code actually looks like today

    Solver layer (1,536 lines total)

    • src/fl/gfx/rgbw_colorimetric.h (461 lines)
    • src/fl/gfx/rgbw_colorimetric.cpp.hpp (1,075 lines)

    Everything lives in namespace fl::colorimetric_detail. The header inlines the leaf-level math (cct_to_xy, xyY_to_XYZ, invert3x3, matvec3, barycentric_xy, build_source_matrix, nnls3, hermite_basis, quantize_u8/lut_cell) and declares the heavier work: ProfileCache, LutTable, build_profile_cache, solve_strict_subgamut[_xy], solve_wx_lp_legacy, solve_wx_overdrive, build_lut, lookup_lut, solve_rgbcct. All function definitions and the heavyweight data types are gated by FASTLED_RGBW_COLORIMETRIC.

    Public RGBW config surface (src/fl/gfx/rgbw.h)

    • struct DiodeProfile carries R/G/B chromaticity and W chromaticity, peak luminances including lum_w, nominal_cct, plus the post-bug(rgbw): kRGBWColorimetric* skips source-RGB → LED-XYZ conversion — solver has no target white point #2705 source-space fields (input_xy_r/g/b/w).
    • set_rgbw_colorimetric_profile(), enable_rgbw_colorimetric_lut(...), disable_rgbw_colorimetric_lut(), rgbw_colorimetric_lut_enabled(), rgbw_colorimetric_lut_memory_bytes(...).
    • RGBW_MODE::kRGBWColorimetric and kRGBWColorimetricBoosted enumerators, dispatched through the rgb_2_rgbw(MODE, ...) switch in rgbw.h:317.

    Pixel-load integration (src/pixel_controller.h:591-629)

    The ordering called out as required in the issue already holds for RGBW, and the structural reason is the mColorAdjustment.premixed field:

    CRGB input
      -> mColorAdjustment.premixed   // correction x temperature x brightness (+ optional HD gamma)
      -> fl::rgb_2_rgbw(rgbw_mode, w_color_temp, r, g, b,
                        premixed.r, premixed.g, premixed.b,   // scale inputs to solver
                        &out_r, &out_g, &out_b, &out_w)       // solver outputs
      -> rgbw_partial_reorder(...)                            // wire-order placement only
      -> chipset emits b0_out/b1_out/b2_out/b3_out as-is
    

    So the colorimetric solve already sees post-policy values, and the chipset side does not apply any further per-channel mutation between solver output and the wire. The structural invariant the issue asks for in the RGB path is exactly the one the RGBW path already enforces.

    Where RGB-only would plug in (src/pixel_controller.h:581-586)

    FASTLED_FORCE_INLINE void loadAndScaleRGB(fl::u8 *b0_out, fl::u8 *b1_out,
                                              fl::u8 *b2_out) {
        *b0_out = loadAndScale0();
        *b1_out = loadAndScale1();
        *b2_out = loadAndScale2();
    }

    loadAndScale{0,1,2} already apply mColorAdjustment.premixed. So the RGB-only colorimetric hook has a single, clean integration point: between loadAndScale* and the assignment to b*_out. Every chipset that drives RGB strips calls loadAndScaleRGB (src/fl/chipsets/hd108.h:62, src/platforms/adafruit/clockless_real.hpp:82, src/platforms/arm/teensy/teensy4_common/clockless_objectfled.cpp.hpp:143, src/platforms/arm/rp/rpcommon/clockless_rp_pio_auto.cpp.hpp:405, ...) so a single change there covers all chipsets without per-driver edits.

    Planned fix (assumes the open questions resolve as recommended below)

    Land in three PRs, in order, each independently mergeable and each leaving the RGBW path bit-exact unless explicitly noted.

    PR 1 — Extract colorimetric_response (refactor only, zero behavior change)

    New files:

    • src/fl/gfx/colorimetric_response.h — moves cct_to_xy, xyY_to_XYZ, invert3x3, matvec3, barycentric_xy, build_source_matrix, nnls3, hermite_basis, quantize_u8, quantize_lut_cell, the kLut* constants, the LutInterp enum, and a new RGB-only EmitterProfile (see below) into namespace fl::colorimetric_response.
    • src/fl/gfx/colorimetric_response.cpp.hpp — empty for now; reserved for shared cache-construction helpers if PR 2 needs them.

    rgbw_colorimetric.h/.cpp.hpp keep all RGBW-specific code: ProfileCache, solve_strict_subgamut*, solve_wx_lp_legacy, solve_wx_overdrive, solve_rgbcct, the W-extraction / boosted / RGBCCT logic. They #include "fl/gfx/colorimetric_response.h" and use the moved helpers via colorimetric_response::xyY_to_XYZ(...) etc.

    Build-system: shared module compiles whenever either FASTLED_RGBW_COLORIMETRIC or FASTLED_RGB_COLORIMETRIC is defined (new gate, see Open Question 1). With both undefined the file compiles to nothing (inline-only header). Existing _build.cpp.hpp already lists rgbw_colorimetric.cpp.hpp; add the new module the same way.

    Tests:

    • tests/fl/gfx/colorimetric_response.cpp — new. Exercises the moved helpers in isolation of any RGBW topology: cct_to_xy round-trip at 2700K/4000K/6500K against the gist's reference values, invert3x3/matvec3 identities, build_source_matrix reproducing the published sRGB matrix from Rec.709 primaries + D65, nnls3 on a known under-determined target, hermite_basis at t=0/0.5/1.
    • tests/fl/gfx/rgbw_colorimetric.cpp — unchanged. Re-runs prove the extraction is bit-exact.

    Validation command: bash test colorimetric_response and bash test rgbw_colorimetric. Acceptance criterion #1 ("no intentional RGBW output changes") is met because every RGBW code path keeps calling the same functions via the new namespace.

    PR 2 — Split EmitterProfile out of DiodeProfile

    New struct in colorimetric_response.h:

    struct EmitterProfile {
        float xy_r[2], xy_g[2], xy_b[2];
        float lum_r, lum_g, lum_b;
        float input_xy_r[2], input_xy_g[2], input_xy_b[2], input_xy_w[2];
    };

    DiodeProfile in rgbw.h is rewritten as the RGB profile plus the RGBW-only fields, preserving its current layout and field names so existing user code keeps compiling:

    struct DiodeProfile {                      // identical wire layout to today
        float xy_r[2], xy_g[2], xy_b[2];
        float xy_w[2];                          // RGBW-only
        float lum_r, lum_g, lum_b, lum_w;       // lum_w RGBW-only
        int nominal_cct;                        // RGBW-only
        float input_xy_r[2], input_xy_g[2], input_xy_b[2], input_xy_w[2];
    
        EmitterProfile as_rgb() const;          // copy RGB-only fields out
    };

    The keep-current-layout constraint matters: kRgbwDefaultProfile and user-built profiles get checked into firmware sketches; changing struct layout is a public-API break we should not take. as_rgb() is the public adapter for users who happen to have a DiodeProfile and want to drive an RGB strip with the same primaries.

    set_input_gamut(DiodeProfile*, InputGamut) gets an EmitterProfile* overload too, so the same named-gamut helper works for both profile shapes.

    Tests: extend tests/fl/gfx/rgbw_colorimetric.cpp with one case proving DiodeProfile::as_rgb() produces the right EmitterProfile. Existing tests untouched.

    PR 3 — RGB colorimetric solve + pixel-load integration

    New solver entrypoint in colorimetric_response.h (definition .cpp.hpp gated by FASTLED_RGB_COLORIMETRIC):

    struct RgbProfileCache {
        const EmitterProfile* profile;
        float P_R[3], P_G[3], P_B[3];    // measured emitter columns in absolute device XYZ
        float P_RGB_inv[3][3];           // [R G B]^-1
        float M_src[3][3];               // source-space -> device XYZ
        bool has_source_space;
    };
    
    void build_rgb_profile_cache(const EmitterProfile* p, RgbProfileCache* cache) FL_NOEXCEPT;
    
    // Solve s_rgb (source-gamut linear) -> device-emitter drive triple.
    // Native single-axis is exact identity; the general case is a one-shot
    // 3x3 solve (no W axis to project against -- vastly simpler than RGBW).
    bool solve_rgb_colorimetric(const RgbProfileCache& cache,
                                float s_r, float s_g, float s_b,
                                float out_rgb[3]) FL_NOEXCEPT;

    Implementation is small: with no W diode there is no LP / boosted / RGBCCT mode. The strict path is out_rgb = P_RGB_inv * (M_src * source_rgb) with native single-axis identity and a non-negative clamp at the end. Reuse build_source_matrix, invert3x3, matvec3 from the shared module.

    Public surface in rgbw.h (or a new colorimetric.h if we want the symmetry):

    extern const EmitterProfile kRgbDefaultProfile;       // ships with a sensible WS2812 default
    void set_rgb_colorimetric_profile(const EmitterProfile* p) FL_NOEXCEPT;
    const EmitterProfile* get_rgb_colorimetric_profile() FL_NOEXCEPT;
    void enable_rgb_colorimetric() FL_NOEXCEPT;
    void disable_rgb_colorimetric() FL_NOEXCEPT;
    bool rgb_colorimetric_enabled() FL_NOEXCEPT;
    // (LUT variants follow once needed -- out of scope for first landing.)

    Pixel-load hook in pixel_controller.h:581:

    FASTLED_FORCE_INLINE void loadAndScaleRGB(fl::u8 *b0_out, fl::u8 *b1_out,
                                              fl::u8 *b2_out) {
        fl::u8 r = loadAndScale0();
        fl::u8 g = loadAndScale1();
        fl::u8 b = loadAndScale2();
    #if FASTLED_RGB_COLORIMETRIC
        if (fl::rgb_colorimetric_enabled()) {
            fl::apply_rgb_colorimetric(&r, &g, &b);  // in-place; uses installed profile
        }
    #endif
        *b0_out = r;
        *b1_out = g;
        *b2_out = b;
    }

    This places the solve after correction/temperature/brightness/gamma (which are baked into mColorAdjustment.premixed before loadAndScale* runs) and before the chipset takes the bytes off the iterator — same shape the RGBW path already enforces. No driver edits required.

    Tests (tests/fl/gfx/rgb_colorimetric.cpp, new):

    • Native single-axis identity: (255,0,0) -> (255,0,0), etc.
    • Round-trip on a synthetic profile where source primaries equal emitter primaries: solver is the identity for in-gamut inputs.
    • Rec.709 input gamut driving a wider native gamut: out-of-gamut targets get clamped non-negative, in-gamut targets match the published sRGB -> device matrix to within +/- 1 LSB.
    • Acceptance criterion 6 ("no post-solve per-channel scaling/correction"): synthetic test chipset that records the bytes it sees from loadAndScaleRGB; assert byte-for-byte equality with solve_rgb_colorimetric(premixed) when brightness and correction are non-trivial. This is the closest thing to a falsifiable validation case the issue admits, and it directly proves the structural invariant the issue is asking for.

    Validation commands:

    • bash test rgb_colorimetric — unit-level pass.
    • bash test --cpp — full host suite, proves RGBW path unchanged.
    • bash compile uno --examples Blink — proves the RGB gate is off by default and the AVR build is unaffected (no float math leaks in).
    • bash compile esp32dev --examples Blink and similar — proves the gate works when enabled.

    Reproduction status

    N/A. This is a design / new-feature issue, not a bug report. There is no reporter command, no error message, and no current behavior misbehaving. The acceptance-criterion #6 test described in PR 3 is the closest thing to a falsifiable validation hook, and it is constructive rather than reproductive.

    Open questions for the maintainer

    These are the three questions the issue itself raises; my recommendation on each, plus the rationale:

    1. Compile gate. Recommend a new FASTLED_RGB_COLORIMETRIC gate distinct from FASTLED_RGBW_COLORIMETRIC. The RGBW gate currently pulls in the LP / boosted / RGBCCT solvers + LUT machinery; an RGB-only user shouldn't pay that flash cost. The shared colorimetric_response module compiles when either gate is on. Both gates default to undefined; today's RGBW behavior is preserved bit-exact.

    2. Gamma/power and what the RGB entrypoint accepts. Recommend the entrypoint accepts already-final linear source values. The solver model documented in rgbw_colorimetric.h:11-15 already says "Input RGB is treated as linear-light source-gamut coordinates," and the RGBW path inherits gamma + correction + temperature + brightness via mColorAdjustment.premixed. Re-applying gamma inside the solve would break linearity assumptions the math model depends on. The pixel-load hook in PR 3 above sits at the exact point where this is naturally true.

    3. Public API shape for RGB source gamut + measured emitter profile. Recommend a separate EmitterProfile struct (and a separate set_rgb_colorimetric_profile) rather than overloading DiodeProfile. DiodeProfile carries xy_w / lum_w / nominal_cct which are meaningless for an RGB strip; conflating them encourages users to set ignored fields. DiodeProfile keeps its current layout (public-API compatibility) and gets an as_rgb() adapter. set_input_gamut() gets an EmitterProfile* overload so the named-gamut machinery is shared.

    A fourth question that the issue doesn't pose but matters for binary cost:

    1. Should the default RGB profile ship as Native or Rec709? Today's default RGBW profile (kRgbwDefaultProfile) ships as Native so saturated inputs reach the LED at full drive. The same default is the right call for kRgbDefaultProfile — (255,0,0) lights the red diode at full power, no surprises for first-time users.

    Risks and alternatives considered

    • Risk: layout change to DiodeProfile breaks user firmware. Mitigated by keeping DiodeProfile's field layout identical to today and introducing EmitterProfile as a separate, narrower struct.
    • Risk: the pixel-load hook adds an unconditional branch on every RGB pixel. Mitigated by the #if FASTLED_RGB_COLORIMETRIC gate so sketches that don't define it pay literally zero cost; when defined, the rgb_colorimetric_enabled() predicate is a single bool load that gc-sections folds out for sketches that never call enable_rgb_colorimetric().
    • Alternative considered: integrate inside each chipset driver (rejected). That's exactly the "two correction passes" failure mode the issue is asking to make impossible.
    • Alternative considered: a single combined kColorimetric mode on RGBW_MODE (rejected). RGB strips don't have an RGBW mode enum to begin with — they're driven through loadAndScaleRGB. The cleanest control surface is a separate enable/disable plus an installable EmitterProfile, mirroring how RGBW does it.

    Next step

    I'd like a +1 / -1 on the four answers above (especially Q1 — the gate question — since it shapes how PR 1 lays the build files down). Once those land, the three PRs above can be implemented in order; PR 1 and PR 2 are safe refactors with zero behavior change and can ship first while we iterate on PR 3's exact public-surface naming.

    If any of those four feel like they need more thinking-time, happy to spin out a feat-design: issue per question so the discussion isn't all stacked here.

    cc related: #2748, #3231.

  2. zackees commented on Jun 18, 2026

    @zackees
    MemberAuthor

    Follow-up to my report above: at @zackees's request, here are three candidate answers per open question, plus a recommendation. Each candidate is stated as a position someone could reasonably defend so the tradeoffs are explicit instead of buried in prose.


    Q1 — Compile gate

    A. Share the existing FASTLED_RGBW_COLORIMETRIC gate.
    The gate flips on the whole colorimetric_* family; RGB is just a new entrypoint that compiles when the existing flag is on.

    • ✔ Zero new gate to document; no migration for the RGBWW module (src/fl/gfx/rgbww.cpp.hpp:170 and examples/RGBWW/RGBWW.ino:14 keep working as-is).
    • ✘ RGB-only users pay the flash cost of the LP / boosted / RGBCCT solvers and the LUT machinery (~half of rgbw_colorimetric.cpp.hpp's 1,075 lines). On AVR/ESP8266 that's exactly the cost the gate exists to keep off the board.
    • ✘ Gate name lies about its scope ("RGBW" enables RGB).

    B. Dedicated new gate FASTLED_RGB_COLORIMETRIC; shared module compiles when either gate is on.
    Each solver gates only itself. The new colorimetric_response module's gate is #if FASTLED_RGBW_COLORIMETRIC || FASTLED_RGB_COLORIMETRIC.

    • ✔ Pay-for-what-you-use: RGB-only users get the small RGB solver + shared helpers, nothing else. RGBW-only users see byte-identical output to today.
    • ✔ Matches the existing FastLED convention (FASTLED_HD_COLOR_MIXING, FASTLED_FORCE_SOFTWARE_SPI, etc. — one knob per feature).
    • ✔ Gate names match their surface; future contributors greping for FASTLED_RGB_COLORIMETRIC find the RGB path, not the RGBW one.
    • ✘ Two flags to teach in docs (mitigated: nearly identical phrasing, side-by-side).

    C. Umbrella gate FASTLED_COLORIMETRIC with auto-derived sub-gates *_RGB / *_RGBW / *_RGBWW.
    One opt-in flips on the shared module; sub-gates select which solvers compile. The existing FASTLED_RGBW_COLORIMETRIC becomes a backward-compat alias.

    • ✔ Architecturally clean hierarchy; one knob to "enable colorimetric at all," extra knobs for which family.
    • ✘ Backward-compat aliasing logic is fragile — existing sketches in the wild use the current gate name and a botched alias would silently break their build.
    • ✘ Larger blast radius than the feature actually requires (the issue asks for one new mode, not a gate hierarchy).
    • ✘ Migration story has to be perfect for every example, every README, every doc page. None of that mechanism buys anything users can feel.

    Recommendation: B. Lowest-blast-radius option that satisfies the binary-size requirement in acceptance criterion #7 ("MCU-friendly, no unnecessary binary-size cost"). C is over-engineered for one feature; A leaks RGBW machinery into RGB-only sketches.


    Q2 — Gamma/power and what the RGB entrypoint accepts

    A. Accept already-final linear source values.
    Solve sits between loadAndScale{0,1,2} (which apply mColorAdjustment.premixed = correction × temperature × brightness) and the chipset byte emit. This is the same structural position the RGBW path uses at src/pixel_controller.h:615.

    • ✔ Structurally identical to the RGBW path the issue praises as "the right shape" — same invariant, enforced by code position, not by documentation.
    • ✔ Matches the solver's documented input model in rgbw_colorimetric.h:11-15 ("Input RGB is treated as linear-light source-gamut coordinates") — mColorAdjustment.premixed is linear in 8-bit space, no gamma encoding is applied to it.
    • ✔ Zero driver changes; one hook point in loadAndScaleRGB.
    • ✘ Relies on mColorAdjustment staying linear in the future. Mitigation: this risk already exists for RGBW and would need to be solved for both at once, not just for RGB.

    B. Fold gamma/power into an explicit pre-solve adjustment stage.
    Introduce pre_solve_adjust(CRGB&) inside loadAndScale* that applies brightness/correction/temperature/gamma in a documented order, then calls solve, then emits.

    • ✔ Ordering becomes explicit in code rather than implicit in field semantics; a future contributor inserting a gamma stage can't silently break the colorimetric path.
    • ✘ FastLED currently has no standalone gamma-correction stage in loadAndScale* — HD color mixing applies a five-bit HD gamma at emit time (src/fl/gfx/five_bit_hd_gamma.h), and user-set gamma is applied earlier in user code. Forcing a pre-solve gamma stage requires reorganizing how HD color mixing interacts with the colorimetric path.
    • ✘ Structurally invasive for a marginal benefit; expands the patch surface from one hook in pixel_controller.h to a reorganization of mColorAdjustment and HD gamma plumbing.

    C. Accept raw CRGB and re-apply correction/temperature/brightness/gamma inside the solver.
    The solver becomes a single black box: feed it the user-set pixel and the active adjustment policy, get out the emitter drive.

    • ✔ Single integration point for users; impossible to misuse the ordering because the solver controls it.
    • ✘ Doubles the per-pixel work the solver has to do (it has to re-apply scaling the iterator already applied).
    • ✘ Defeats the existing loadAndScale* infrastructure that every chipset is wired to.
    • ✘ Requires plumbing mColorAdjustment + brightness into the solver call site — a public-API expansion for the colorimetric API.
    • ✘ Strictly worse than A on every axis except "fewer hook points."

    Recommendation: A. Smallest mechanism that satisfies the issue's stated invariant. The solver's documented input model already says linear source-gamut coordinates, mColorAdjustment.premixed already is linear, and the hook point exists. B is the alternative-by-symmetry but the bigger refactor doesn't buy anything users can feel; C is strictly worse.


    Q3 — Public API shape for RGB source gamut + measured emitter profile

    A. Separate EmitterProfile struct + parallel set_rgb_colorimetric_profile() API; DiodeProfile keeps its current layout and gains an as_rgb() adapter.
    The RGB struct contains R/G/B chromaticity + luminance + source-space input_xy_*. DiodeProfile keeps xy_w / lum_w / nominal_cct for RGBW use.

    • ✔ Each profile struct only carries fields meaningful to its mode — no silently-ignored fields, no "what does setting xy_w here even mean" question.
    • ✔ Mirrors the existing RGBW public surface naming: set_rgb_colorimetric_profile, get_rgb_colorimetric_profile, kRgbDefaultProfile line up 1:1 with the RGBW equivalents.
    • ✔ Users with an existing measured DiodeProfile get a one-call adapter (profile.as_rgb()).
    • ✔ set_input_gamut() picks up an EmitterProfile* overload — trivial.
    • ✘ Two profile types in the public API surface (mitigated: they're documented as "use the one that matches your strip type").

    B. Single DiodeProfile for both; the RGB solver simply ignores xy_w / lum_w / nominal_cct.
    set_rgb_colorimetric_profile(const DiodeProfile*) reuses the same struct.

    • ✔ One struct to teach; users who already have a measured RGBW profile reuse it directly.
    • ✘ Encourages users to set fields the solver ignores; first-time users will hit "I set xy_w for my SK6812 RGB strip, why doesn't it change anything?".
    • ✘ Couples RGB and RGBW config evolution forever — any change to DiodeProfile's public surface has to think about both modes.
    • ✘ Doc has to say "if you're using RGB-only, ignore these fields," which is a signal of a bad API shape.

    C. New composite ColorimetricProfile struct with an explicit has_w discriminator; both solvers read from it.
    One struct, runtime-discriminated, prepared for RGBWW / RGBCCT extension.

    • ✔ Architecturally elegant; one place to extend for future LED topologies.
    • ✘ Public-API change to today's DiodeProfile — every sketch with kRgbwDefaultProfile references either breaks or needs an alias.
    • ✘ Larger struct = larger embedded default constant in flash. The existing kRgbwDefaultProfile is already a non-trivial constant; doubling it for a discriminator users never read is wasteful.
    • ✘ Runtime discriminator means the solver branches on has_w for every per-pixel call (cheap, but adds code on the hot path).
    • ✘ Solves a problem we don't have — there's no RGBWWW or quad-W strip on the roadmap that would need this flexibility.

    Recommendation: A. Strict separation keeps each surface sharp; the one-line as_rgb() adapter handles the "I already have a DiodeProfile" migration; named-gamut helper picks up an overload (trivial). B's silent-ignore behavior is the standard "ergonomic shortcut, future-maintenance trap" pattern; C is architecturally aspirational for a problem we don't have.


    Q4 — Default RGB profile gamut (not posed by the issue but matters)

    A. Native LED gamut + D65 white (mirror today's kRgbwDefaultProfile).

    • ✔ Consistent with today's RGBW default behavior — saturated input (255,0,0) reaches full red diode drive; users get no surprise color shift when they enable the new mode.
    • ✔ Discoverability: the colorimetric path is identity at the default config until the user explicitly opts in to a named input gamut, so enabling the gate alone is safe.
    • ✘ Out-of-the-box the colorimetric solve doesn't change observed output (zero perceived value until set_input_gamut(profile, InputGamut::Rec709) is called).

    B. Rec.709 / sRGB.

    • ✔ Matches what most authored content (video frames, web images, ambilight, screenshots) actually is; the colorimetric path delivers visible benefit immediately.
    • ✘ Divergence from RGBW default; saturated (255,0,0) no longer reaches full red diode drive — surprise color shift for users who enable the gate "just to try it."
    • ✘ Requires explicit migration documentation for sketches that expected today's "primaries are native" behavior.

    C. Track the active RGBW profile's input gamut when both gates are on; Native otherwise.

    • ✔ Removes divergence when both modes are configured.
    • ✘ Ties two independent settings together; requires runtime coordination; complicates the "what gamut am I in" mental model.
    • ✘ Solves a coordination problem most users don't actually have.

    Recommendation: A. Consistency with the existing RGBW default outweighs out-of-the-box visible benefit, and users who want sRGB semantics already have set_input_gamut(profile, InputGamut::Rec709) one call away. Defaulting to a behavior change is a quiet migration trap.


    Net answer

    Question Pick One-line rationale
    Q1 — gate B — new FASTLED_RGB_COLORIMETRIC, shared module compiles when either gate is on Smallest gate that satisfies the binary-size criterion; matches existing FastLED gate convention.
    Q2 — gamma/power A — accept already-final linear source values Same structural shape as the working RGBW path; solver's documented input model already says linear.
    Q3 — API shape A — separate EmitterProfile struct + parallel setter, DiodeProfile.as_rgb() adapter Strict separation, no silent-ignore fields, mirrors existing RGBW public surface.
    Q4 — default gamut A — Native LED gamut + D65 white Consistency with the existing RGBW default; sRGB semantics are one call away.

    If those four land, PR 1 (extract colorimetric_response) and PR 2 (split EmitterProfile) are pure refactors with byte-identical RGBW output, safe to ship while we iterate on PR 3's exact public-surface naming. Happy to open them in that order once you give a +/-1.

    cc related: #2748, #3231.

  3. JChalka commented on Jun 18, 2026

    @JChalka
    Contributor

    You should slow down a bit until I finish and verify my work, finding an RGB entrypoint makes sense but it should not bring in color temperature correction as the colrimetric response already handles this, I also already am handling the split from RGBW to a shared colorimetric_response.h/cpp.hpp : JChalka@2e2d051#diff-a299db0de2f120c537a91456ce343c396a95486adb04fd4ef5f19b58108ee6df

    JChalka@a7a0cab

    You do not have the means to verify this unless you have a colorimeter or spectrophotometer and this is work that needs to be verified with real measurements, I appreciate the excitement but these measurements take time and I'm already mid-implementation and have phases laid out

  4. zackees commented on Jun 19, 2026

    @zackees
    MemberAuthor

    Design discussion resolved. Implementation contract filed as #3255 — captures the consolidated plan (no compile gate, per-strip fl::variant<RGBW_MODE, ColorimetricMode> + fl::shared_ptr<const DiodeProfile>, tier-gated on FL_PLATFORM_HAS_TINY_MEMORY, clean break on the enum entries, three-PR phasing). Closing this when #3255 lands.

  5. zackees commented on Jun 28, 2026

    @zackees
    MemberAuthor

    Closing after pushing the current RGBW colorimetric codec/profile API and example in draft PR #3435: #3435

  6. moved this from Triage to Done in FastLED Trackeron Jun 28, 2026
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