Changes to the contrast/brightness/gamma formula for both hardware and shader gamma correction. Mainly makes a correction with the shader version where contrast/brightness being negative values would clip them inappropriately.

This commit is contained in:
raa-eruanna 2016-09-21 15:08:53 -04:00 committed by Christoph Oelckers
parent af699dcebc
commit 72491049e0
2 changed files with 3 additions and 3 deletions

View file

@ -250,8 +250,8 @@ void OpenGLFrameBuffer::DoSetGamma()
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
{ {
double val = i * contrast - (contrast - 1) * 127; double val = i * contrast - (contrast - 1) * 127;
if(gamma != 1) val = pow(val, invgamma) / norm;
val += bright * 128; val += bright * 128;
if(gamma != 1) val = pow(val, invgamma) / norm;
gammaTable[i] = gammaTable[i + 256] = gammaTable[i + 512] = (WORD)clamp<double>(val*256, 0, 0xffff); gammaTable[i] = gammaTable[i + 256] = gammaTable[i + 512] = (WORD)clamp<double>(val*256, 0, 0xffff);
} }

View file

@ -9,9 +9,9 @@ uniform float Brightness;
vec4 ApplyGamma(vec4 c) vec4 ApplyGamma(vec4 c)
{ {
vec3 val = max(c.rgb * Contrast - (Contrast - 1.0) * 0.5, vec3(0.0)); vec3 val = c.rgb * Contrast - (Contrast - 1.0) * 0.5;
val = pow(val, vec3(InvGamma));
val += Brightness * 0.5; val += Brightness * 0.5;
val = pow(val, vec3(InvGamma));
return vec4(val, c.a); return vec4(val, c.a);
} }