From f662c629e31f29d38b1817722e623bbd648a57d3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 11 Aug 2021 10:06:22 +0200 Subject: [PATCH] - ensure that shadowmap indices only get set when shadowmaps are enabled. Having valid indices set when shadowmaps are off would cause the shader to run the full checks for all lights. --- src/common/rendering/hwrenderer/data/hw_shadowmap.h | 5 +++++ src/rendering/hwrenderer/hw_dynlightdata.cpp | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/rendering/hwrenderer/data/hw_shadowmap.h b/src/common/rendering/hwrenderer/data/hw_shadowmap.h index f82e368b2a..e755c0f599 100644 --- a/src/common/rendering/hwrenderer/data/hw_shadowmap.h +++ b/src/common/rendering/hwrenderer/data/hw_shadowmap.h @@ -57,6 +57,11 @@ public: mLights[index + 3] = r; } + bool Enabled() const + { + return mAABBTree != nullptr; + } + protected: // Upload the AABB-tree to the GPU void UploadAABBTree(); diff --git a/src/rendering/hwrenderer/hw_dynlightdata.cpp b/src/rendering/hwrenderer/hw_dynlightdata.cpp index f65b031726..044d34d3d5 100644 --- a/src/rendering/hwrenderer/hw_dynlightdata.cpp +++ b/src/rendering/hwrenderer/hw_dynlightdata.cpp @@ -29,6 +29,7 @@ #include "a_dynlight.h" #include "hw_dynlightdata.h" #include"hw_cvars.h" +#include "v_video.h" #include "hwrenderer/scene/hw_drawstructs.h" // If we want to share the array to avoid constant allocations it needs to be thread local unless it'd be littered with expensive synchronization. @@ -107,7 +108,7 @@ void AddLightToList(FDynLightData &dld, int group, FDynamicLight * light, bool f } float shadowIndex; - if (gl_light_shadowmap) // note: with gl_light_shadowmap switched off, we cannot rely on properly set indices anymore. + if (screen->mShadowMap.Enabled()) // note: with shadowmaps switched off, we cannot rely on properly set indices anymore. { shadowIndex = light->mShadowmapIndex + 1.0f; }