Revert "- add dithering to present shader"

This reverts commit 60ae0915b9.

This was extremely slow on intel, the dither matrix was recreated on every frame even when not used.
This commit is contained in:
drfrag666 2018-11-12 11:11:28 +01:00
parent 709a573355
commit c2a3895bfe
7 changed files with 1 additions and 40 deletions

View file

@ -155,8 +155,6 @@ EXTERN_CVAR(Float, vid_contrast)
EXTERN_CVAR(Float, vid_saturation)
EXTERN_CVAR(Int, gl_satformula)
CVAR(Bool, gl_dither, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
void FGLRenderer::RenderScreenQuad()
{
mVBO->BindVBO();
@ -887,7 +885,6 @@ void FGLRenderer::DrawPresentTexture(const GL_IRECT &box, bool applyGamma)
mPresentShader->Saturation.Set(clamp<float>(vid_saturation, -15.0f, 15.f));
mPresentShader->GrayFormula.Set(static_cast<int>(gl_satformula));
}
mPresentShader->ColorScale.Set(static_cast<float>(gl_dither ? 255.0f : 0.0f));
mPresentShader->Scale.Set(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight());
RenderScreenQuad();
}

View file

@ -49,7 +49,6 @@ void FPresentShaderBase::Init(const char * vtx_shader_name, const char * program
Saturation.Init(mShader, "Saturation");
GrayFormula.Init(mShader, "GrayFormula");
Scale.Init(mShader, "UVScale");
ColorScale.Init(mShader, "ColorScale");
}
void FPresentShader::Bind()

View file

@ -15,7 +15,6 @@ public:
FBufferedUniform1f Saturation;
FBufferedUniform1i GrayFormula;
FBufferedUniform2f Scale;
FBufferedUniform1f ColorScale;
protected:
virtual void Init(const char * vtx_shader_name, const char * program_name);

View file

@ -45,7 +45,6 @@ EXTERN_CVAR(Float, vid_saturation)
EXTERN_CVAR(Float, vid_brightness)
EXTERN_CVAR(Float, vid_contrast)
EXTERN_CVAR(Int, gl_satformula)
EXTERN_CVAR(Bool, gl_dither)
EXTERN_CVAR(Bool, fullscreen)
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
@ -113,7 +112,6 @@ static void prepareInterleavedPresent(FPresentStereoShaderBase& shader)
shader.Saturation.Set(clamp<float>(vid_saturation, -15.0f, 15.0f));
shader.GrayFormula.Set(static_cast<int>(gl_satformula));
}
shader.ColorScale.Set(static_cast<float>(gl_dither ? 255.0f : 0.0f));
shader.Scale.Set(
GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(),
GLRenderer->mScreenViewport.height / (float)GLRenderer->mBuffers->GetHeight());

View file

@ -2813,7 +2813,6 @@ GLPREFMNU_LENS = "Lens distortion effect";
GLPREFMNU_SSAO = "Ambient occlusion quality";
GLPREFMNU_SSAO_PORTALS = "Portals with AO";
GLPREFMNU_FXAA = "FXAA Quality";
GLPREFMNU_DITHER = "Dither output";
GLPREFMNU_PALTONEMAPORDER = "Tonemap Palette Order";
GLPREFMNU_PALTONEMAPPOWER = "Tonemap Palette Exponent";
GLPREFMNU_SWLMBANDED = "Banded SW Lightmode";

View file

@ -2363,7 +2363,6 @@ OptionMenu "OpenGLOptions" protected
Option "$GLPREFMNU_SSAO", gl_ssao, "SSAOModes"
Slider "$GLPREFMNU_SSAO_PORTALS", gl_ssao_portals, 0.0, 4.0, 1.0, 0
Option "$GLPREFMNU_FXAA", gl_fxaa, "FXAAQuality"
Option "$GLPREFMNU_DITHER", gl_dither, "OnOff"
StaticText " "
Slider "$GLPREFMNU_PALTONEMAPPOWER", gl_paltonemap_powtable, 0.2, 3.0, 0.1, 1
Option "$GLPREFMNU_PALTONEMAPORDER", gl_paltonemap_reverselookup, "LookupOrder"

View file

@ -8,7 +8,6 @@ uniform float Contrast;
uniform float Brightness;
uniform float Saturation;
uniform int GrayFormula;
uniform float ColorScale;
vec4 ApplyGamma(vec4 c)
{
@ -23,36 +22,7 @@ vec4 ApplyGamma(vec4 c)
return vec4(val, c.a);
}
#define HALFSTEP 1./65.
float DitherMatrix[64] = float[](
0.0 / 16.0 + HALFSTEP * 1, 8.0 / 16.0 + HALFSTEP * 1, 2.0 / 16.0 + HALFSTEP * 1, 10.0 / 16.0 + HALFSTEP * 1,
0.0 / 16.0 + HALFSTEP * 3, 8.0 / 16.0 + HALFSTEP * 3, 2.0 / 16.0 + HALFSTEP * 3, 10.0 / 16.0 + HALFSTEP * 3,
12.0 / 16.0 + HALFSTEP * 1, 4.0 / 16.0 + HALFSTEP * 1, 14.0 / 16.0 + HALFSTEP * 1, 6.0 / 16.0 + HALFSTEP * 1,
12.0 / 16.0 + HALFSTEP * 3, 4.0 / 16.0 + HALFSTEP * 3, 14.0 / 16.0 + HALFSTEP * 3, 6.0 / 16.0 + HALFSTEP * 3,
3.0 / 16.0 + HALFSTEP * 1, 11.0 / 16.0 + HALFSTEP * 1, 1.0 / 16.0 + HALFSTEP * 1, 9.0 / 16.0 + HALFSTEP * 1,
3.0 / 16.0 + HALFSTEP * 3, 11.0 / 16.0 + HALFSTEP * 3, 1.0 / 16.0 + HALFSTEP * 3, 9.0 / 16.0 + HALFSTEP * 3,
15.0 / 16.0 + HALFSTEP * 1, 7.0 / 16.0 + HALFSTEP * 1, 13.0 / 16.0 + HALFSTEP * 1, 5.0 / 16.0 + HALFSTEP * 1,
15.0 / 16.0 + HALFSTEP * 3, 7.0 / 16.0 + HALFSTEP * 3, 13.0 / 16.0 + HALFSTEP * 3, 5.0 / 16.0 + HALFSTEP * 3,
0.0 / 16.0 + HALFSTEP * 4, 8.0 / 16.0 + HALFSTEP * 4, 2.0 / 16.0 + HALFSTEP * 4, 10.0 / 16.0 + HALFSTEP * 4,
0.0 / 16.0 + HALFSTEP * 2, 8.0 / 16.0 + HALFSTEP * 2, 2.0 / 16.0 + HALFSTEP * 2, 10.0 / 16.0 + HALFSTEP * 2,
12.0 / 16.0 + HALFSTEP * 4, 4.0 / 16.0 + HALFSTEP * 4, 14.0 / 16.0 + HALFSTEP * 4, 6.0 / 16.0 + HALFSTEP * 4,
12.0 / 16.0 + HALFSTEP * 2, 4.0 / 16.0 + HALFSTEP * 2, 14.0 / 16.0 + HALFSTEP * 2, 6.0 / 16.0 + HALFSTEP * 2,
3.0 / 16.0 + HALFSTEP * 4, 11.0 / 16.0 + HALFSTEP * 4, 1.0 / 16.0 + HALFSTEP * 4, 9.0 / 16.0 + HALFSTEP * 4,
3.0 / 16.0 + HALFSTEP * 2, 11.0 / 16.0 + HALFSTEP * 2, 1.0 / 16.0 + HALFSTEP * 2, 9.0 / 16.0 + HALFSTEP * 2,
15.0 / 16.0 + HALFSTEP * 4, 7.0 / 16.0 + HALFSTEP * 4, 13.0 / 16.0 + HALFSTEP * 4, 5.0 / 16.0 + HALFSTEP * 4,
15.0 / 16.0 + HALFSTEP * 2, 7.0 / 16.0 + HALFSTEP * 2, 13.0 / 16.0 + HALFSTEP * 2, 5.0 / 16.0 + HALFSTEP * 2
);
vec4 Dither(vec4 c)
{
if (ColorScale == 0.0)
return c;
ivec2 pos = ivec2(gl_FragCoord.xy) & 7;
float threshold = DitherMatrix[pos.x + (pos.y << 3)];
return vec4(floor(c.rgb * ColorScale + threshold) / ColorScale, c.a);
}
void main()
{
FragColor = Dither(ApplyGamma(texture(InputTexture, TexCoord)));
FragColor = ApplyGamma(texture(InputTexture, TexCoord));
}