- 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.
This commit is contained in:
Christoph Oelckers 2021-08-11 10:06:22 +02:00
parent 436ec28e94
commit f662c629e3
2 changed files with 7 additions and 1 deletions

View file

@ -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();

View file

@ -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;
}