From c92d016e43cf4b989993bd486e4b5be4234063f8 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Sun, 26 May 2024 00:00:24 +0300 Subject: [PATCH] Don't sort scene light list by camera distance if the limit isn't reached and PP doesn't need it Also don't clip it to the single UBO scene light limit if the lighting method isn't actually single UBO --- components/sceneutil/lightmanager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/sceneutil/lightmanager.cpp b/components/sceneutil/lightmanager.cpp index 221f419c74..0377905c9d 100644 --- a/components/sceneutil/lightmanager.cpp +++ b/components/sceneutil/lightmanager.cpp @@ -1161,8 +1161,10 @@ namespace SceneUtil } const bool fillPPLights = mPPLightBuffer && it->first->getName() == Constants::SceneCamera; + const bool sceneLimitReached = getLightingMethod() == LightingMethod::SingleUBO + && it->second.size() > static_cast(getMaxLightsInScene() - 1); - if (fillPPLights || getLightingMethod() == LightingMethod::SingleUBO) + if (fillPPLights || sceneLimitReached) { auto sorter = [](const LightSourceViewBound& left, const LightSourceViewBound& right) { return left.mViewBound.center().length2() - left.mViewBound.radius2() @@ -1183,7 +1185,7 @@ namespace SceneUtil } } - if (it->second.size() > static_cast(getMaxLightsInScene() - 1)) + if (sceneLimitReached) it->second.resize(getMaxLightsInScene() - 1); } }