From aa07dab8abbc6fd0f1769c5daf1fe81b7b0c7c2a Mon Sep 17 00:00:00 2001 From: SNMetamorph <25657591+SNMetamorph@users.noreply.github.com> Date: Wed, 8 Dec 2021 19:49:18 +0400 Subject: [PATCH] engine: added feature flag ENGINE_LINEAR_GAMMA_SPACE --- common/enginefeatures.h | 1 + engine/common/gamma.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/common/enginefeatures.h b/common/enginefeatures.h index 03999a82c..dc949dbf3 100644 --- a/common/enginefeatures.h +++ b/common/enginefeatures.h @@ -25,5 +25,6 @@ GNU General Public License for more details. #define ENGINE_COMPENSATE_QUAKE_BUG (1<<5) // compensate stupid quake bug (inverse pitch) for mods where this bug is fixed #define ENGINE_IMPROVED_LINETRACE (1<<6) // new traceline that tracing through alphatextures #define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine +#define ENGINE_LINEAR_GAMMA_SPACE (1<<8) // disable influence of gamma/brightness cvars to textures/lightmaps, for mods with custom renderer #endif//FEATURES_H diff --git a/engine/common/gamma.c b/engine/common/gamma.c index 7440def47..e6c902273 100644 --- a/engine/common/gamma.c +++ b/engine/common/gamma.c @@ -15,6 +15,7 @@ GNU General Public License for more details. #include "common.h" #include "xash3d_mathlib.h" +#include "enginefeatures.h" //----------------------------------------------------------------------------- // Gamma conversion support @@ -78,10 +79,16 @@ void BuildGammaTable( float lightgamma, float brightness ) byte LightToTexGamma( byte b ) { - return lightgammatable[b]; + if( host.features & ENGINE_LINEAR_GAMMA_SPACE ) + return b; + else + return lightgammatable[b]; } byte TextureToGamma( byte b ) { - return texgammatable[b]; + if( host.features & ENGINE_LINEAR_GAMMA_SPACE ) + return b; + else + return texgammatable[b]; }