Just sharing an interesting read, for the modern LED programmer.
https://learn.adafruit.com/led-tricks-gamma-correction
The FastLED HSV to RGB conversion code has basic gamma correction built in, via the function “dim8(…)” If you’re programming with our HSV colors, you probably don’t need (or want) additional correction.
Admittedly, dim8 is an approximation, but it’s smaller than using a 256-byte lookup table, and basically just as fast, especially if your table is in PROGMEM. And if your table ISN’T in PROGMEM, you’re paying a 256-byte RAM penalty.
I have a better gamma correction in the pipeline, but it’s not in 2.1 yet.
Also: that article doesn’t really deal with the difference in sensitivity of the eye to R G and B colors, which are all different; that’s why we also provide the setCorrection( RGB) method to set color correction for each led strip.
I’m a bit of a psycho-perceptual color-science geek. In case that wasn’t already obvious.
Sometimes it’s nice to understand why and how things work within the FastLED library. I enjoy learning the principles/fundamentals alongside already functioning code. As an engineer type, the physical limitations of the human eye are very interesting to me.
Absolutely! I didn’t mean to belittle the information in that article, I was just being snobby about the implementation. I’m a little low on sleep; forgive the terse tone. (Just back from that thing in the desert; I got a full eight hours of sleep… over the last three days…)
Welcome back! Your point of view on things are valued by many here.
Can you explain how the dim8() function works? Do you pass it as the brightness value?
led[i].cshv(hue, sat ,dim8(bright)) ?
Well, yes, except that the CHSV constructor has that exact code basically built in already, so using it there would be redundant, and would “overdim” the brightnesses.
But if you’re making CRGB values, you can ‘dim8(…)’ each channel, or better yet ‘dim8_video(…)’, which is what the CHSV ctor uses.
dim8 and dim8_video take a (brightness) value and apply a fast approximation of a gamma curve. It’s not mathematically correct for that, but it’s tiny, extremely fast, and looks pretty close in most cases.
More info on the github wiki iirc.
Hmm… interesting… there is so much functionality in this library… I am constantly catching up. I am just trying to understand what has been created vs. what I have already done.
So just to clarify if I have a LED already set and then do say LED[i].dim8_video(192).
This would be the same as doing (LED[i].setHSV(Hue,Sat, gamma[192]); assuming same Hue and Sat values as were set in LED[i] before?
My apologies, but my brain just gave the 10% battery warning. I’ll try to give clear answer after I plug it in for the night.