mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 23:11:58 +00:00
- added a grayscale formula selector
This commit is contained in:
parent
a2c9cb8156
commit
0d8b7c55ef
6 changed files with 21 additions and 2 deletions
|
@ -150,6 +150,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)
|
EXTERN_CVAR(Float, vid_saturation)
|
||||||
|
EXTERN_CVAR(Int, gl_satformula)
|
||||||
|
|
||||||
|
|
||||||
void FGLRenderer::RenderScreenQuad()
|
void FGLRenderer::RenderScreenQuad()
|
||||||
|
@ -867,6 +868,7 @@ void FGLRenderer::DrawPresentTexture(const GL_IRECT &box, bool applyGamma)
|
||||||
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, -15.0f, 15.f));
|
mPresentShader->Saturation.Set(clamp<float>(vid_saturation, -15.0f, 15.f));
|
||||||
|
mPresentShader->GrayFormula.Set(static_cast<int>(gl_satformula));
|
||||||
}
|
}
|
||||||
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();
|
||||||
|
|
|
@ -47,6 +47,7 @@ void FPresentShaderBase::Init(const char * vtx_shader_name, const char * program
|
||||||
Contrast.Init(mShader, "Contrast");
|
Contrast.Init(mShader, "Contrast");
|
||||||
Brightness.Init(mShader, "Brightness");
|
Brightness.Init(mShader, "Brightness");
|
||||||
Saturation.Init(mShader, "Saturation");
|
Saturation.Init(mShader, "Saturation");
|
||||||
|
GrayFormula.Init(mShader, "GrayFormula");
|
||||||
Scale.Init(mShader, "UVScale");
|
Scale.Init(mShader, "UVScale");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ public:
|
||||||
FBufferedUniform1f Contrast;
|
FBufferedUniform1f Contrast;
|
||||||
FBufferedUniform1f Brightness;
|
FBufferedUniform1f Brightness;
|
||||||
FBufferedUniform1f Saturation;
|
FBufferedUniform1f Saturation;
|
||||||
|
FBufferedUniform1i GrayFormula;
|
||||||
FBufferedUniform2f Scale;
|
FBufferedUniform2f Scale;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
EXTERN_CVAR(Float, vid_saturation)
|
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(Int, gl_satformula)
|
||||||
EXTERN_CVAR(Bool, fullscreen)
|
EXTERN_CVAR(Bool, fullscreen)
|
||||||
EXTERN_CVAR(Int, win_x) // screen pixel position of left of display window
|
EXTERN_CVAR(Int, win_x) // screen pixel position of left of display window
|
||||||
EXTERN_CVAR(Int, win_y) // screen pixel position of top of display window
|
EXTERN_CVAR(Int, win_y) // screen pixel position of top of display window
|
||||||
|
@ -101,6 +102,7 @@ static void prepareInterleavedPresent(FPresentStereoShaderBase& shader)
|
||||||
shader.InvGamma.Set(1.0f);
|
shader.InvGamma.Set(1.0f);
|
||||||
shader.Contrast.Set(1.0f);
|
shader.Contrast.Set(1.0f);
|
||||||
shader.Brightness.Set(0.0f);
|
shader.Brightness.Set(0.0f);
|
||||||
|
shader.Saturation.Set(1.0f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -108,6 +110,7 @@ static void prepareInterleavedPresent(FPresentStereoShaderBase& shader)
|
||||||
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, -15.0f, 15.0f));
|
shader.Saturation.Set(clamp<float>(vid_saturation, -15.0f, 15.0f));
|
||||||
|
shader.GrayFormula.Set(static_cast<int>(gl_satformula));
|
||||||
}
|
}
|
||||||
shader.Scale.Set(
|
shader.Scale.Set(
|
||||||
GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(),
|
GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(),
|
||||||
|
|
|
@ -77,7 +77,15 @@ CUSTOM_CVAR (Float, vid_saturation, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
{
|
{
|
||||||
if (screen != NULL)
|
if (screen != NULL)
|
||||||
{
|
{
|
||||||
screen->SetGamma(Gamma); //SetContrast (self);
|
screen->SetGamma(Gamma);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CUSTOM_CVAR(Int, gl_satformula, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||||
|
{
|
||||||
|
if (screen != NULL)
|
||||||
|
{
|
||||||
|
screen->SetGamma(Gamma);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,16 @@ uniform float InvGamma;
|
||||||
uniform float Contrast;
|
uniform float Contrast;
|
||||||
uniform float Brightness;
|
uniform float Brightness;
|
||||||
uniform float Saturation;
|
uniform float Saturation;
|
||||||
|
uniform int GrayFormula;
|
||||||
|
|
||||||
vec4 ApplyGamma(vec4 c)
|
vec4 ApplyGamma(vec4 c)
|
||||||
{
|
{
|
||||||
vec3 valgray;
|
vec3 valgray;
|
||||||
if (Saturation != 1.0) // attempt to cool things a bit, this calculation makes the GPU run really hot
|
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;
|
if (GrayFormula == 0)
|
||||||
|
valgray = vec3(c.r + c.g + c.b) * (1 - Saturation) / 3 + c.rgb * Saturation;
|
||||||
|
else
|
||||||
|
valgray = vec3(0.3 * c.r + 0.56 * c.g + 0.14 * c.b) * (1 - Saturation) + c.rgb * Saturation;
|
||||||
else
|
else
|
||||||
valgray = c.rgb;
|
valgray = c.rgb;
|
||||||
vec3 val = valgray * Contrast - (Contrast - 1.0) * 0.5;
|
vec3 val = valgray * Contrast - (Contrast - 1.0) * 0.5;
|
||||||
|
|
Loading…
Reference in a new issue