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))