- added a vid_saturation control - works in postprocessing, only.

This commit is contained in:
Rachael Alexanderson 2017-06-25 19:33:07 -04:00
parent 6a402c28d8
commit 63da6e70c0
6 changed files with 18 additions and 1 deletions

View file

@ -149,6 +149,7 @@ CVAR(Float, gl_menu_blur, -1.0f, CVAR_ARCHIVE)
EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_brightness)
EXTERN_CVAR(Float, vid_contrast) EXTERN_CVAR(Float, vid_contrast)
EXTERN_CVAR(Float, vid_saturation)
void FGLRenderer::RenderScreenQuad() void FGLRenderer::RenderScreenQuad()
@ -858,12 +859,14 @@ void FGLRenderer::DrawPresentTexture(const GL_IRECT &box, bool applyGamma)
mPresentShader->InvGamma.Set(1.0f); mPresentShader->InvGamma.Set(1.0f);
mPresentShader->Contrast.Set(1.0f); mPresentShader->Contrast.Set(1.0f);
mPresentShader->Brightness.Set(0.0f); mPresentShader->Brightness.Set(0.0f);
mPresentShader->Saturation.Set(1.0f);
} }
else else
{ {
mPresentShader->InvGamma.Set(1.0f / clamp<float>(Gamma, 0.1f, 4.f)); mPresentShader->InvGamma.Set(1.0f / clamp<float>(Gamma, 0.1f, 4.f));
mPresentShader->Contrast.Set(clamp<float>(vid_contrast, 0.1f, 3.f)); mPresentShader->Contrast.Set(clamp<float>(vid_contrast, 0.1f, 3.f));
mPresentShader->Brightness.Set(clamp<float>(vid_brightness, -0.8f, 0.8f)); mPresentShader->Brightness.Set(clamp<float>(vid_brightness, -0.8f, 0.8f));
mPresentShader->Saturation.Set(clamp<float>(vid_saturation, -3.0f, 3.f));
} }
mPresentShader->Scale.Set(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight()); mPresentShader->Scale.Set(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight());
RenderScreenQuad(); RenderScreenQuad();

View file

@ -46,6 +46,7 @@ void FPresentShaderBase::Init(const char * vtx_shader_name, const char * program
InvGamma.Init(mShader, "InvGamma"); InvGamma.Init(mShader, "InvGamma");
Contrast.Init(mShader, "Contrast"); Contrast.Init(mShader, "Contrast");
Brightness.Init(mShader, "Brightness"); Brightness.Init(mShader, "Brightness");
Saturation.Init(mShader, "Saturation");
Scale.Init(mShader, "UVScale"); Scale.Init(mShader, "UVScale");
} }

View file

@ -12,6 +12,7 @@ public:
FBufferedUniform1f InvGamma; FBufferedUniform1f InvGamma;
FBufferedUniform1f Contrast; FBufferedUniform1f Contrast;
FBufferedUniform1f Brightness; FBufferedUniform1f Brightness;
FBufferedUniform1f Saturation;
FBufferedUniform2f Scale; FBufferedUniform2f Scale;
protected: protected:

View file

@ -41,6 +41,7 @@
#include "gl/system/gl_framebuffer.h" #include "gl/system/gl_framebuffer.h"
#include "gl/shaders/gl_present3dRowshader.h" #include "gl/shaders/gl_present3dRowshader.h"
EXTERN_CVAR(Float, vid_saturation)
EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_brightness)
EXTERN_CVAR(Float, vid_contrast) EXTERN_CVAR(Float, vid_contrast)
EXTERN_CVAR(Bool, fullscreen) EXTERN_CVAR(Bool, fullscreen)
@ -106,6 +107,7 @@ static void prepareInterleavedPresent(FPresentStereoShaderBase& shader)
shader.InvGamma.Set(1.0f / clamp<float>(Gamma, 0.1f, 4.f)); shader.InvGamma.Set(1.0f / clamp<float>(Gamma, 0.1f, 4.f));
shader.Contrast.Set(clamp<float>(vid_contrast, 0.1f, 3.f)); shader.Contrast.Set(clamp<float>(vid_contrast, 0.1f, 3.f));
shader.Brightness.Set(clamp<float>(vid_brightness, -0.8f, 0.8f)); shader.Brightness.Set(clamp<float>(vid_brightness, -0.8f, 0.8f));
shader.Saturation.Set(clamp<float>(vid_saturation, -3.0f, 3.0f));
} }
shader.Scale.Set( shader.Scale.Set(
GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(), GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(),

View file

@ -73,6 +73,14 @@ CUSTOM_CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
} }
} }
CUSTOM_CVAR (Float, vid_saturation, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
{
if (screen != NULL)
{
screen->SetGamma(Gamma); //SetContrast (self);
}
}
// Do some tinkering with the menus so that certain options only appear // Do some tinkering with the menus so that certain options only appear
// when they are actually valid. // when they are actually valid.

View file

@ -6,10 +6,12 @@ uniform sampler2D InputTexture;
uniform float InvGamma; uniform float InvGamma;
uniform float Contrast; uniform float Contrast;
uniform float Brightness; uniform float Brightness;
uniform float Saturation;
vec4 ApplyGamma(vec4 c) vec4 ApplyGamma(vec4 c)
{ {
vec3 val = c.rgb * Contrast - (Contrast - 1.0) * 0.5; vec3 valgray = (0.3 * c.r + 0.59 * c.g + 0.11 * c.b) * (1 - Saturation) + c.rgb * Saturation;
vec3 val = valgray * Contrast - (Contrast - 1.0) * 0.5;
val += Brightness * 0.5; val += Brightness * 0.5;
val = pow(max(val, vec3(0.0)), vec3(InvGamma)); val = pow(max(val, vec3(0.0)), vec3(InvGamma));
return vec4(val, c.a); return vec4(val, c.a);