Slightly improve colorize's luminance method

Before I was using coefficents from another formula I forget the source of, but over time I've stopped liking how it looked -- just considers greens far too bright. Here I'm trying out BT.601 coefficents instead (https://en.wikipedia.org/wiki/Rec._601).

These are also the coefficients Doom itself used for invulnerability's invert effect (if you ignore the typo Carmack made :p), so this checks out.
This commit is contained in:
Sally Coolatta 2022-12-15 22:08:29 -05:00
parent 5ffcfb558f
commit 4feba88327

View file

@ -24,11 +24,12 @@
--------------------------------------------------*/
UINT8 K_ColorRelativeLuminance(UINT8 r, UINT8 g, UINT8 b)
{
UINT32 redweight = 1063 * r;
UINT32 greenweight = 3576 * g;
UINT32 blueweight = 361 * b;
UINT32 brightness = (redweight + greenweight + blueweight) / 5000;
return min(brightness, UINT8_MAX);
// These are the BT.601 coefficents
// See also: https://en.wikipedia.org/wiki/Rec._601
UINT32 redweight = 299 * r;
UINT32 greenweight = 587 * g;
UINT32 blueweight = 114 * b;
return min((redweight + greenweight + blueweight) / 1000, UINT8_MAX);
}
/*--------------------------------------------------