Skip to content

Apply a curve for color correction? #909

Open

Description

@203Null

My ws2812Bs has different curve for each RGB channel, so when I calibrated it at the maximum brightness, it will look off again at lower brightness.

If I applied the curve before the send it to FastLED, the brightness feature will scale linearly on the curve, which is not ideal.

I know that I can build a maximum match > brightness > curve system outside of the FastLED but I do want to utilize the dithering feature that build in brightness feature provided.

So is there's a way to apply a curve/lookup table after the brightness process or can I sent a float into FastLED for dithering?

Activity

  1. hfuerst commented on Oct 28, 2022

    @hfuerst

    Me Too.
    Compare Lights of different LEDs (WS2812-PL9823). It would be good to have Curves for Correction.

  2. added
    area: core
    status: stale
    status: triage
    on Apr 16, 2026
  3. added
    deferred
    on Aug 1, 2026
  4. zackees commented on Aug 1, 2026

    @zackees
    Member

    Deferred by automated triage: Genuine unimplemented feature, verified still missing. The ask is a per-channel response curve applied AFTER brightness scaling and BEFORE dithering, on clockless (WS2812) output. What exists today does not cover it: (1) setCorrection()/setTemperature() are per-channel but LINEAR scale factors applied via ColorAdjustment.premixed, not curves; (2) gamma correction exists only on SPI chipsets -- APA102HD/SK9822HD via five_bit_hd_gamma.cpp.hpp, and HD108 via encoders/hd108.h; (3) Channel::setGamma(float) exists (src/fl/channels/channel.cpp.hpp:779) but mGamma is consumed ONLY in the UCS7604 encode path at channel.cpp.hpp:349-350 -- it does nothing for WS2812; (4) fl::gamma_2_8()/Gamma8 (src/fl/math/ease.h) are usable from sketch code, but applying them before handing pixels to FastLED reproduces exactly the problem reported -- setBrightness then scales linearly on top of the curve. Deferred rather than implemented because of three real design questions: (a) per-channel curves means three 256-byte LUTs = 768 bytes, which is prohibitive on AVR-class targets (ATmega328P has 2KB total) so it needs PROGMEM plus a memory gate like SKETCH_HAS_LARGE_MEMORY; (b) the insertion point must be inside the pixel pipeline between scale and dither -- see PixelController::loadAndScale (src/pixel_controller.h:462-464) where scale() then dither() run per byte -- which is the hottest loop in the library and is cycle-counted on AVR; (c) it overlaps setCorrection/setTemperature, which already apply per-channel adjustment, so the API needs to define how a curve composes with those rather than adding a third independent knob. Per CLAUDE.md any new global setter belongs on CFastLED. Two requesters (dyq888 2019, hfuerst 2022) with the same need: matching mixed LED types (WS2812 vs PL9823) whose per-channel responses differ.

  5. zackees commented on Aug 1, 2026

    @zackees
    Member

    Marking deferred — I checked, and this genuinely isn't available yet. Recording exactly what exists so the gap is precise.

    Your framing was right

    If I applied the curve before I send it to FastLED, the brightness feature will scale linearly on the curve, which is not ideal.

    That's the crux, and it's why the obvious workaround doesn't work. The curve has to be applied after brightness scaling, and pre-correcting in sketch code can't achieve that.

    What exists today — and why none of it covers this

    what it does why it isn't this
    setCorrection() / setTemperature() per-channel scaling linear multipliers, not curves — and applied before brightness
    APA102HD, SK9822HD 5-bit gamma via five_bit_hd_gamma SPI chipsets only; nothing for WS2812
    HD108 16-bit, always gamma corrected SPI only
    Channel::setGamma(float) looks promising… mGamma is consumed only in the UCS7604 encode path (channel.cpp.hpp:349). It does nothing for WS2812.
    fl::gamma_2_8() / Gamma8 real gamma LUTs callable from a sketch, but only before FastLED — the exact thing you ruled out

    So: gamma exists in FastLED, but only on chipsets whose encoder had somewhere to put it. The clockless path has no such hook.

    Why it isn't a small change

    1. Memory. Per-channel curves are three 256-byte LUTs — 768 bytes. An ATmega328P has 2 KB of RAM total. That needs PROGMEM plus a SKETCH_HAS_LARGE_MEMORY-style gate, which is a design decision rather than an implementation detail.

    2. It lands in the hottest loop. The insertion point is between scale and dither in PixelController::loadAndScale (src/pixel_controller.h:462-464), which runs per byte per LED and is cycle-counted on AVR. A LUT lookup there is not free.

    3. It overlaps existing knobs. setCorrection and setTemperature already apply per-channel adjustment. A curve has to define how it composes with those, or you get three knobs that interact confusingly. (Per CLAUDE.md, any new global setter also belongs on CFastLED.)

    Meanwhile

    If you can use a clocked chipset, APA102HD / SK9822HD give you gamma applied at the right point in the pipeline today — that's precisely the problem those HD variants exist to solve.

    @hfuerst — your case (matching WS2812 against PL9823) is the same need and a good argument for it: mixed strips with different per-channel responses can't be reconciled with a single linear correction.

    Deferred rather than closed: the request is legitimate, still unmet, and now has the design questions written down.

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

    area: coredeferredstatus: stalestatus: triage

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions