From 6132e45e252a943e13b7ce6c2a6140769d5ead44 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 25 Jul 2025 16:00:44 +0200 Subject: [PATCH] Fix shadow lights checking loop if shadows are disabled --- Source/Engine/Renderer/ShadowsPass.cpp | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Source/Engine/Renderer/ShadowsPass.cpp b/Source/Engine/Renderer/ShadowsPass.cpp index 3937f8554..910ec3cef 100644 --- a/Source/Engine/Renderer/ShadowsPass.cpp +++ b/Source/Engine/Renderer/ShadowsPass.cpp @@ -1070,26 +1070,26 @@ void ShadowsPass::SetupShadows(RenderContext& renderContext, RenderContextBatch& // 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 Array shadowedLights; - for (auto& light : renderContext.List->DirectionalLights) + if (_shadowMapFormat != PixelFormat::Unknown && EnumHasAllFlags(renderContext.View.Flags, ViewFlags::Shadows) && !checkIfSkipPass()) { - if (light.CanRenderShadow(renderContext.View)) - shadowedLights.Add(&light); - } - for (auto& light : renderContext.List->SpotLights) - { - if (light.CanRenderShadow(renderContext.View)) - shadowedLights.Add(&light); - } - for (auto& light : renderContext.List->PointLights) - { - if (light.CanRenderShadow(renderContext.View)) - shadowedLights.Add(&light); + for (auto& light : renderContext.List->DirectionalLights) + { + if (light.CanRenderShadow(renderContext.View)) + shadowedLights.Add(&light); + } + for (auto& light : renderContext.List->SpotLights) + { + if (light.CanRenderShadow(renderContext.View)) + shadowedLights.Add(&light); + } + for (auto& light : renderContext.List->PointLights) + { + if (light.CanRenderShadow(renderContext.View)) + shadowedLights.Add(&light); + } } const auto currentFrame = Engine::FrameCount; - if (_shadowMapFormat == PixelFormat::Unknown || - EnumHasNoneFlags(renderContext.View.Flags, ViewFlags::Shadows) || - checkIfSkipPass() || - shadowedLights.IsEmpty()) + if (shadowedLights.IsEmpty()) { // 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(TEXT("Shadows"), false))