mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-05-10 10:51:42 +00:00
Merge branch 'slightly-better-colorize' into 'master'
Slightly improve colorize's luminance method See merge request KartKrew/Kart!810
This commit is contained in:
commit
b02aa713d3
1 changed files with 12 additions and 5 deletions
|
|
@ -24,11 +24,18 @@
|
||||||
--------------------------------------------------*/
|
--------------------------------------------------*/
|
||||||
UINT8 K_ColorRelativeLuminance(UINT8 r, UINT8 g, UINT8 b)
|
UINT8 K_ColorRelativeLuminance(UINT8 r, UINT8 g, UINT8 b)
|
||||||
{
|
{
|
||||||
UINT32 redweight = 1063 * r;
|
double redWeight = ((r * 1.0) / UINT8_MAX);
|
||||||
UINT32 greenweight = 3576 * g;
|
double greenWeight = ((g * 1.0) / UINT8_MAX);
|
||||||
UINT32 blueweight = 361 * b;
|
double blueWeight = ((b * 1.0) / UINT8_MAX);
|
||||||
UINT32 brightness = (redweight + greenweight + blueweight) / 5000;
|
double brightness = 0.5;
|
||||||
return min(brightness, UINT8_MAX);
|
|
||||||
|
redWeight = pow(redWeight, 2.2) * 0.2126;
|
||||||
|
greenWeight = pow(greenWeight, 2.2) * 0.7152;
|
||||||
|
blueWeight = pow(greenWeight, 2.2) * 0.0722;
|
||||||
|
|
||||||
|
brightness = pow(redWeight + greenWeight + blueWeight, 1.0 / 2.2);
|
||||||
|
|
||||||
|
return (UINT8)(brightness * UINT8_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------
|
/*--------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue