New GBC LCD correction for Gambatte palette from documented shader research https://forums.libretro.com/t/real-gba-and-ds-phat-colors/1540 (#1917)
This commit is contained in:
parent
f9c6e02943
commit
0bfe178650
|
@ -51,9 +51,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
public static Triple GambatteColor(Triple c)
|
||||
{
|
||||
Triple ret;
|
||||
ret.r = (c.r * 13 + c.g * 2 + c.b) >> 1;
|
||||
ret.g = (c.g * 3 + c.b) << 1;
|
||||
ret.b = (c.r * 3 + c.g * 2 + c.b * 11) >> 1;
|
||||
double gammaR = Math.Pow((double)c.r / 31, 2.2);
|
||||
double gammaG = Math.Pow((double)c.g / 31, 2.2);
|
||||
double gammaB = Math.Pow((double)c.b / 31, 2.2);
|
||||
ret.r = (int)(Math.Pow(gammaR * .87 + gammaG * .18 - gammaB * .05, 1/ 2.2) * 255 + .5);
|
||||
ret.g = (int)(Math.Pow(gammaG * .66 + gammaR * .115 + gammaB * .225, 1/ 2.2) * 255 + .5);
|
||||
ret.b = (int)(Math.Pow(gammaB * .79 + gammaR * .14 + gammaG * .07, 1/ 2.2) * 255 + .5);
|
||||
ret.r = Math.Max(0, Math.Min(255, ret.r));
|
||||
ret.g = Math.Max(0, Math.Min(255, ret.g));
|
||||
ret.b = Math.Max(0, Math.Min(255, ret.b));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue