Fix shadow lights checking loop if shadows are disabled

This commit is contained in:
Wojtek Figat
2025-07-25 16:00:44 +02:00
parent bb37f980ed
commit 6132e45e25

View File

@@ -1070,26 +1070,26 @@ void ShadowsPass::SetupShadows(RenderContext& renderContext, RenderContextBatch&
// Early out and skip shadows setup if no lights is actively casting shadows // Early out and skip shadows setup if no lights is actively casting shadows
// RenderBuffers will automatically free any old ShadowsCustomBuffer after a few frames if we don't update LastFrameUsed // RenderBuffers will automatically free any old ShadowsCustomBuffer after a few frames if we don't update LastFrameUsed
Array<RenderLightData*, RendererAllocation> shadowedLights; Array<RenderLightData*, RendererAllocation> shadowedLights;
for (auto& light : renderContext.List->DirectionalLights) if (_shadowMapFormat != PixelFormat::Unknown && EnumHasAllFlags(renderContext.View.Flags, ViewFlags::Shadows) && !checkIfSkipPass())
{ {
if (light.CanRenderShadow(renderContext.View)) for (auto& light : renderContext.List->DirectionalLights)
shadowedLights.Add(&light); {
} if (light.CanRenderShadow(renderContext.View))
for (auto& light : renderContext.List->SpotLights) shadowedLights.Add(&light);
{ }
if (light.CanRenderShadow(renderContext.View)) for (auto& light : renderContext.List->SpotLights)
shadowedLights.Add(&light); {
} if (light.CanRenderShadow(renderContext.View))
for (auto& light : renderContext.List->PointLights) shadowedLights.Add(&light);
{ }
if (light.CanRenderShadow(renderContext.View)) for (auto& light : renderContext.List->PointLights)
shadowedLights.Add(&light); {
if (light.CanRenderShadow(renderContext.View))
shadowedLights.Add(&light);
}
} }
const auto currentFrame = Engine::FrameCount; const auto currentFrame = Engine::FrameCount;
if (_shadowMapFormat == PixelFormat::Unknown || if (shadowedLights.IsEmpty())
EnumHasNoneFlags(renderContext.View.Flags, ViewFlags::Shadows) ||
checkIfSkipPass() ||
shadowedLights.IsEmpty())
{ {
// Invalidate any existing custom buffer that could have been used by the same task (eg. when rendering 6 sides of env probe) // Invalidate any existing custom buffer that could have been used by the same task (eg. when rendering 6 sides of env probe)
if (auto* old = (ShadowsCustomBuffer*)renderContext.Buffers->FindCustomBuffer<ShadowsCustomBuffer>(TEXT("Shadows"), false)) if (auto* old = (ShadowsCustomBuffer*)renderContext.Buffers->FindCustomBuffer<ShadowsCustomBuffer>(TEXT("Shadows"), false))