From 5380d3f3934c3d4e852b2338d0bb975cc67bcdcc Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Thu, 29 Dec 2022 21:32:23 -0800 Subject: [PATCH] Clean up global shadow max blur size variable --- .../pfConsole/pfConsoleCommands.cpp | 10 +++++---- .../FeatureLib/pfDXPipeline/plDXPipeline.cpp | 5 +++-- .../PubUtilLib/plGLight/plShadowMaster.cpp | 1 + .../PubUtilLib/plGLight/plShadowMaster.h | 22 +++++++++++-------- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp index 9f42cc4ade..d4820bef8d 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp @@ -1240,10 +1240,12 @@ PF_CONSOLE_CMD( Graphics_Shadow, "...", "Max shadowmap blur size." ) { - extern float blurScale; - if( numParams > 0 ) - { - blurScale = (float)atof( params[ 0 ] ); + float blurScale; + if (numParams > 0) { + blurScale = (float)atof(params[0]); + plShadowMaster::SetGlobalMaxBlur(blurScale); + } else { + blurScale = plShadowMaster::GetGlobalMaxBlur(); } pfConsolePrintF(PrintString, "Max shadowmap Blur {f}", blurScale); } diff --git a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXPipeline.cpp b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXPipeline.cpp index c901519a59..4cc5eb42b8 100644 --- a/Sources/Plasma/FeatureLib/pfDXPipeline/plDXPipeline.cpp +++ b/Sources/Plasma/FeatureLib/pfDXPipeline/plDXPipeline.cpp @@ -110,6 +110,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "plGImage/plMipmap.h" #include "plGLight/plLightInfo.h" #include "plGLight/plShadowCaster.h" +#include "plGLight/plShadowMaster.h" #include "plGLight/plShadowSlave.h" #include "plMessage/plDeviceRecreateMsg.h" #include "plResMgr/plLocalization.h" @@ -9629,7 +9630,6 @@ const char *plDXPipeline::IGetDXFormatName( D3DFORMAT format ) -float blurScale = -1.f; static const int kL2NumSamples = 3; // Log2(4) // IBlurShadowMap ////////////////////////////////////////////////////////////////// @@ -10898,7 +10898,8 @@ bool plDXPipeline::IRenderShadowCaster(plShadowSlave* slave) } // Debug only. - if( blurScale >= 0.f ) + float blurScale = plShadowMaster::GetGlobalMaxBlur(); + if (blurScale >= 0.f) slave->fBlurScale = blurScale; // If this shadow requests being blurred, do it. diff --git a/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp b/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp index fb1b36a6d5..caaad1178a 100644 --- a/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp +++ b/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp @@ -66,6 +66,7 @@ uint32_t plShadowMaster::fGlobalMaxSize = 512; float plShadowMaster::fGlobalMaxDist = 160.f; // PERSPTEST // float plShadowMaster::fGlobalMaxDist = 100000.f; // PERSPTEST float plShadowMaster::fGlobalVisParm = 1.f; +float plShadowMaster::fGlobalMaxBlur = -1.f; void plShadowMaster::SetGlobalShadowQuality(float s) { diff --git a/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.h b/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.h index 8b0ea40266..eca7ede423 100644 --- a/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.h +++ b/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.h @@ -74,19 +74,20 @@ class plShadowMaster : public plObjInterface protected: // Global clamp on shadow map size and stuff - static uint32_t fGlobalMaxSize; - static float fGlobalMaxDist; - static float fGlobalVisParm; + static uint32_t fGlobalMaxSize; + static float fGlobalMaxDist; + static float fGlobalVisParm; + static float fGlobalMaxBlur; // Constant parameter(s) for this master. - float fAttenDist; - float fMaxDist; - float fMinDist; + float fAttenDist; + float fMaxDist; + float fMinDist; - uint32_t fMaxSize; - uint32_t fMinSize; + uint32_t fMaxSize; + uint32_t fMinSize; - float fPower; + float fPower; // Temp data used for one frame and recycled. hsPoolVector> fSlavePool; @@ -166,6 +167,9 @@ class plShadowMaster : public plObjInterface static void SetGlobalShadowQuality(float s); static float GetGlobalShadowQuality() { return fGlobalVisParm; } + + static void SetGlobalMaxBlur(float s) { fGlobalMaxBlur = s; } + static float GetGlobalMaxBlur() { return fGlobalMaxBlur; } };