- expanded hard limits for saturation to -15.0/15.0

- added menu option for saturation
- tried to get the new saturation shader to consume less GPU power by turning it off when it is 1.0
This commit is contained in:
Rachael Alexanderson 2017-06-26 03:50:49 -04:00
parent 63da6e70c0
commit bd02893ce7
5 changed files with 14 additions and 8 deletions

View file

@ -866,7 +866,7 @@ void FGLRenderer::DrawPresentTexture(const GL_IRECT &box, bool applyGamma)
mPresentShader->InvGamma.Set(1.0f / clamp<float>(Gamma, 0.1f, 4.f));
mPresentShader->Contrast.Set(clamp<float>(vid_contrast, 0.1f, 3.f));
mPresentShader->Brightness.Set(clamp<float>(vid_brightness, -0.8f, 0.8f));
mPresentShader->Saturation.Set(clamp<float>(vid_saturation, -3.0f, 3.f));
mPresentShader->Saturation.Set(clamp<float>(vid_saturation, -15.0f, 15.f));
}
mPresentShader->Scale.Set(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight());
RenderScreenQuad();

View file

@ -107,7 +107,7 @@ static void prepareInterleavedPresent(FPresentStereoShaderBase& shader)
shader.InvGamma.Set(1.0f / clamp<float>(Gamma, 0.1f, 4.f));
shader.Contrast.Set(clamp<float>(vid_contrast, 0.1f, 3.f));
shader.Brightness.Set(clamp<float>(vid_brightness, -0.8f, 0.8f));
shader.Saturation.Set(clamp<float>(vid_saturation, -3.0f, 3.0f));
shader.Saturation.Set(clamp<float>(vid_saturation, -15.0f, 15.0f));
}
shader.Scale.Set(
GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(),

View file

@ -2658,6 +2658,7 @@ DSPLYMNU_GLOPT = "OpenGL Renderer";
DSPLYMNU_SWOPT = "Software Renderer";
DSPLYMNU_GAMMA = "Gamma correction";
DSPLYMNU_CONTRAST = "Contrast";
DSPLYMNU_SATURATION = "Saturation";
DSPLYMNU_HWGAMMA = "Hardware Gamma";
// OpenGL Options

View file

@ -742,6 +742,7 @@ OptionMenu "VideoOptions" protected
Slider "$DSPLYMNU_GAMMA", "Gamma", 0.75, 3.0, 0.05, 2
Slider "$DSPLYMNU_BRIGHTNESS", "vid_brightness", -0.8,0.8, 0.05,2
Slider "$DSPLYMNU_CONTRAST", "vid_contrast", 0.1, 3.0, 0.1
Slider "$DSPLYMNU_SATURATION", "vid_saturation", -3.0, 3.0, 0.25
Option "$DSPLYMNU_HWGAMMA", "vid_hwgamma", "HWGammaModes"
Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff"

View file

@ -10,7 +10,11 @@ uniform float Saturation;
vec4 ApplyGamma(vec4 c)
{
vec3 valgray = (0.3 * c.r + 0.59 * c.g + 0.11 * c.b) * (1 - Saturation) + c.rgb * Saturation;
vec3 valgray;
if (Saturation != 1.0) // attempt to cool things a bit, this calculation makes the GPU run really hot
valgray = (0.3 * c.r + 0.59 * c.g + 0.11 * c.b) * (1 - Saturation) + c.rgb * Saturation;
else
valgray = c.rgb;
vec3 val = valgray * Contrast - (Contrast - 1.0) * 0.5;
val += Brightness * 0.5;
val = pow(max(val, vec3(0.0)), vec3(InvGamma));