mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
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:
parent
5ffcfb558f
commit
4feba88327
1 changed files with 6 additions and 5 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue