From 46a57fdfa1846a2e312ad12afd6a7af048252ccd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 17 May 2018 20:51:42 +0200 Subject: [PATCH] - moved the postprocessing CVARs to hwrenderer. --- src/CMakeLists.txt | 3 +- src/gl/renderer/gl_postprocess.cpp | 87 -------------- src/gl/shaders/gl_fxaashader.h | 13 +-- src/gl/shaders/gl_postprocessshader.cpp | 2 +- .../postprocessing/hw_postprocess_cvars.cpp | 110 ++++++++++++++++++ .../postprocessing/hw_postprocess_cvars.h | 54 +++++++++ .../hw_postprocessshader.cpp | 2 +- .../hw_postprocessshader.h | 0 src/r_data/gldefs.cpp | 2 +- 9 files changed, 171 insertions(+), 102 deletions(-) create mode 100644 src/hwrenderer/postprocessing/hw_postprocess_cvars.cpp create mode 100644 src/hwrenderer/postprocessing/hw_postprocess_cvars.h rename src/hwrenderer/{shaders => postprocessing}/hw_postprocessshader.cpp (98%) rename src/hwrenderer/{shaders => postprocessing}/hw_postprocessshader.h (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6c2dae16c..0acecbe6a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1056,7 +1056,8 @@ set (PCH_SOURCES hwrenderer/dynlights/hw_aabbtree.cpp hwrenderer/dynlights/hw_shadowmap.cpp hwrenderer/scene/hw_skydome.cpp - hwrenderer/shaders/hw_postprocessshader.cpp + hwrenderer/postprocessing/hw_postprocess_cvars.cpp + hwrenderer/postprocessing/hw_postprocessshader.cpp hwrenderer/textures/hw_material.cpp hwrenderer/textures/hw_precache.cpp hwrenderer/utility/hw_clock.cpp diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 3714dc283..1cecd4fde 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -52,93 +52,6 @@ #include "gl/textures/gl_hwtexture.h" #include "r_videoscale.h" -//========================================================================== -// -// CVARs -// -//========================================================================== -CVAR(Bool, gl_bloom, false, CVAR_ARCHIVE); -CUSTOM_CVAR(Float, gl_bloom_amount, 1.4f, CVAR_ARCHIVE) -{ - if (self < 0.1f) self = 0.1f; -} - -CVAR(Float, gl_exposure_scale, 1.3f, CVAR_ARCHIVE) -CVAR(Float, gl_exposure_min, 0.35f, CVAR_ARCHIVE) -CVAR(Float, gl_exposure_base, 0.35f, CVAR_ARCHIVE) -CVAR(Float, gl_exposure_speed, 0.05f, CVAR_ARCHIVE) - -CUSTOM_CVAR(Int, gl_tonemap, 0, CVAR_ARCHIVE) -{ - if (self < 0 || self > 5) - self = 0; -} - -CUSTOM_CVAR(Int, gl_bloom_kernel_size, 7, CVAR_ARCHIVE) -{ - if (self < 3 || self > 15 || self % 2 == 0) - self = 7; -} - -CVAR(Bool, gl_lens, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) - -CVAR(Float, gl_lens_k, -0.12f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -CVAR(Float, gl_lens_kcube, 0.1f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -CVAR(Float, gl_lens_chromatic, 1.12f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) - -CUSTOM_CVAR(Int, gl_fxaa, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -{ - if (self < 0 || self >= FFXAAShader::Count) - { - self = 0; - } -} - -CUSTOM_CVAR(Int, gl_ssao, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -{ - if (self < 0 || self > 3) - self = 0; -} - -CUSTOM_CVAR(Int, gl_ssao_portals, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -{ - if (self < 0) - self = 0; -} - -CVAR(Float, gl_ssao_strength, 0.7, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -CVAR(Int, gl_ssao_debug, 0, 0) -CVAR(Float, gl_ssao_bias, 0.2f, 0) -CVAR(Float, gl_ssao_radius, 80.0f, 0) -CUSTOM_CVAR(Float, gl_ssao_blur, 16.0f, 0) -{ - if (self < 0.1f) self = 0.1f; -} - -CUSTOM_CVAR(Float, gl_ssao_exponent, 1.8f, 0) -{ - if (self < 0.1f) self = 0.1f; -} - -CUSTOM_CVAR(Float, gl_paltonemap_powtable, 2.0f, CVAR_ARCHIVE | CVAR_NOINITCALL) -{ - if (GLRenderer) - GLRenderer->ClearTonemapPalette(); -} - -CUSTOM_CVAR(Bool, gl_paltonemap_reverselookup, true, CVAR_ARCHIVE | CVAR_NOINITCALL) -{ - if (GLRenderer) - GLRenderer->ClearTonemapPalette(); -} - -CVAR(Float, gl_menu_blur, -1.0f, CVAR_ARCHIVE) - -EXTERN_CVAR(Float, vid_brightness) -EXTERN_CVAR(Float, vid_contrast) -EXTERN_CVAR(Float, vid_saturation) -EXTERN_CVAR(Int, gl_satformula) - void FGLRenderer::RenderScreenQuad() { mVBO->BindVBO(); diff --git a/src/gl/shaders/gl_fxaashader.h b/src/gl/shaders/gl_fxaashader.h index 5ebcd232e..fc1567d93 100644 --- a/src/gl/shaders/gl_fxaashader.h +++ b/src/gl/shaders/gl_fxaashader.h @@ -28,6 +28,7 @@ #define __GL_FXAASHADER_H__ #include "gl_shaderprogram.h" +#include "hwrenderer/postprocessing/hw_postprocess_cvars.h" class FFXAALumaShader { @@ -41,19 +42,9 @@ private: }; -class FFXAAShader +class FFXAAShader : public IFXAAShader { public: - enum Quality - { - None, - Low, - Medium, - High, - Extreme, - Count - }; - void Bind(); FBufferedUniform1i InputTexture; diff --git a/src/gl/shaders/gl_postprocessshader.cpp b/src/gl/shaders/gl_postprocessshader.cpp index 9d48c88e0..7b357dbec 100644 --- a/src/gl/shaders/gl_postprocessshader.cpp +++ b/src/gl/shaders/gl_postprocessshader.cpp @@ -28,7 +28,7 @@ #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_postprocessstate.h" #include "gl/renderer/gl_renderbuffers.h" -#include "hwrenderer/shaders/hw_postprocessshader.h" +#include "hwrenderer/postprocessing/hw_postprocessshader.h" #include "gl/shaders/gl_postprocessshaderinstance.h" #include "textures/bitmap.h" diff --git a/src/hwrenderer/postprocessing/hw_postprocess_cvars.cpp b/src/hwrenderer/postprocessing/hw_postprocess_cvars.cpp new file mode 100644 index 000000000..d17361cf7 --- /dev/null +++ b/src/hwrenderer/postprocessing/hw_postprocess_cvars.cpp @@ -0,0 +1,110 @@ +// +//--------------------------------------------------------------------------- +// +// Copyright(C) 2016 Magnus Norddahl +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// +/* +** gl_postprocess.cpp +** Post processing effects in the render pipeline +** +*/ + +#include "hw_postprocess_cvars.h" +#include "v_video.h" + +//========================================================================== +// +// CVARs +// +//========================================================================== +CVAR(Bool, gl_bloom, false, CVAR_ARCHIVE); +CUSTOM_CVAR(Float, gl_bloom_amount, 1.4f, CVAR_ARCHIVE) +{ + if (self < 0.1f) self = 0.1f; +} + +CVAR(Float, gl_exposure_scale, 1.3f, CVAR_ARCHIVE) +CVAR(Float, gl_exposure_min, 0.35f, CVAR_ARCHIVE) +CVAR(Float, gl_exposure_base, 0.35f, CVAR_ARCHIVE) +CVAR(Float, gl_exposure_speed, 0.05f, CVAR_ARCHIVE) + +CUSTOM_CVAR(Int, gl_tonemap, 0, CVAR_ARCHIVE) +{ + if (self < 0 || self > 5) + self = 0; +} + +CUSTOM_CVAR(Int, gl_bloom_kernel_size, 7, CVAR_ARCHIVE) +{ + if (self < 3 || self > 15 || self % 2 == 0) + self = 7; +} + +CVAR(Bool, gl_lens, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) + +CVAR(Float, gl_lens_k, -0.12f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Float, gl_lens_kcube, 0.1f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Float, gl_lens_chromatic, 1.12f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) + +CUSTOM_CVAR(Int, gl_fxaa, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (self < 0 || self >= IFXAAShader::Count) + { + self = 0; + } +} + +CUSTOM_CVAR(Int, gl_ssao, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (self < 0 || self > 3) + self = 0; +} + +CUSTOM_CVAR(Int, gl_ssao_portals, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (self < 0) + self = 0; +} + +CVAR(Float, gl_ssao_strength, 0.7f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Int, gl_ssao_debug, 0, 0) +CVAR(Float, gl_ssao_bias, 0.2f, 0) +CVAR(Float, gl_ssao_radius, 80.0f, 0) +CUSTOM_CVAR(Float, gl_ssao_blur, 16.0f, 0) +{ + if (self < 0.1f) self = 0.1f; +} + +CUSTOM_CVAR(Float, gl_ssao_exponent, 1.8f, 0) +{ + if (self < 0.1f) self = 0.1f; +} + +CUSTOM_CVAR(Float, gl_paltonemap_powtable, 2.0f, CVAR_ARCHIVE | CVAR_NOINITCALL) +{ + screen->UpdatePalette(); +} + +CUSTOM_CVAR(Bool, gl_paltonemap_reverselookup, true, CVAR_ARCHIVE | CVAR_NOINITCALL) +{ + screen->UpdatePalette(); +} + +CVAR(Float, gl_menu_blur, -1.0f, CVAR_ARCHIVE) + diff --git a/src/hwrenderer/postprocessing/hw_postprocess_cvars.h b/src/hwrenderer/postprocessing/hw_postprocess_cvars.h new file mode 100644 index 000000000..adde1044b --- /dev/null +++ b/src/hwrenderer/postprocessing/hw_postprocess_cvars.h @@ -0,0 +1,54 @@ +#pragma once + +#include "c_cvars.h" + +class IFXAAShader +{ +public: + enum Quality + { + None, + Low, + Medium, + High, + Extreme, + Count + }; +}; + + + +//========================================================================== +// +// CVARs +// +//========================================================================== +EXTERN_CVAR(Bool, gl_bloom) +EXTERN_CVAR(Float, gl_bloom_amount) +EXTERN_CVAR(Float, gl_exposure_scale) +EXTERN_CVAR(Float, gl_exposure_min) +EXTERN_CVAR(Float, gl_exposure_base) +EXTERN_CVAR(Float, gl_exposure_speed) +EXTERN_CVAR(Int, gl_tonemap) +EXTERN_CVAR(Int, gl_bloom_kernel_size) +EXTERN_CVAR(Bool, gl_lens) +EXTERN_CVAR(Float, gl_lens_k) +EXTERN_CVAR(Float, gl_lens_kcube) +EXTERN_CVAR(Float, gl_lens_chromatic) +EXTERN_CVAR(Int, gl_fxaa) +EXTERN_CVAR(Int, gl_ssao) +EXTERN_CVAR(Int, gl_ssao_portals) +EXTERN_CVAR(Float, gl_ssao_strength) +EXTERN_CVAR(Int, gl_ssao_debug) +EXTERN_CVAR(Float, gl_ssao_bias) +EXTERN_CVAR(Float, gl_ssao_radius) +EXTERN_CVAR(Float, gl_ssao_blur) +EXTERN_CVAR(Float, gl_ssao_exponent) +EXTERN_CVAR(Float, gl_paltonemap_powtable) +EXTERN_CVAR(Bool, gl_paltonemap_reverselookup) +EXTERN_CVAR(Float, gl_menu_blur) +EXTERN_CVAR(Float, vid_brightness) +EXTERN_CVAR(Float, vid_contrast) +EXTERN_CVAR(Float, vid_saturation) +EXTERN_CVAR(Int, gl_satformula) + diff --git a/src/hwrenderer/shaders/hw_postprocessshader.cpp b/src/hwrenderer/postprocessing/hw_postprocessshader.cpp similarity index 98% rename from src/hwrenderer/shaders/hw_postprocessshader.cpp rename to src/hwrenderer/postprocessing/hw_postprocessshader.cpp index da0e60f53..2166af154 100644 --- a/src/hwrenderer/shaders/hw_postprocessshader.cpp +++ b/src/hwrenderer/postprocessing/hw_postprocessshader.cpp @@ -22,7 +22,7 @@ #include "vm.h" #include "d_player.h" -#include "hwrenderer/shaders/hw_postprocessshader.h" +#include "hw_postprocessshader.h" TArray PostProcessShaders; diff --git a/src/hwrenderer/shaders/hw_postprocessshader.h b/src/hwrenderer/postprocessing/hw_postprocessshader.h similarity index 100% rename from src/hwrenderer/shaders/hw_postprocessshader.h rename to src/hwrenderer/postprocessing/hw_postprocessshader.h diff --git a/src/r_data/gldefs.cpp b/src/r_data/gldefs.cpp index d12254ad7..4ebd8283f 100644 --- a/src/r_data/gldefs.cpp +++ b/src/r_data/gldefs.cpp @@ -44,7 +44,7 @@ #include "g_levellocals.h" #include "a_dynlight.h" #include "textures/skyboxtexture.h" -#include "hwrenderer/shaders/hw_postprocessshader.h" +#include "hwrenderer/postprocessing/hw_postprocessshader.h" void AddLightDefaults(FLightDefaults *defaults, double attnFactor); void AddLightAssociation(const char *actor, const char *frame, const char *light);