From d6b99cff8ab7550b5e0316c831087050f19c91c6 Mon Sep 17 00:00:00 2001
From: RunitaiLinden <davep@lindenlab.com>
Date: Wed, 12 Apr 2023 14:51:56 -0500
Subject: [PATCH] SL-19390 Make "Cloud Coverage" feedback into ambient when
 probe ambiance is zero and feedback into probe ambiance when probe ambiance
 is not zero.

---
 indra/llinventory/llsettingssky.cpp |  5 ++++-
 indra/newview/llsettingsvo.cpp      | 16 ++++++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index 46a48e601f8..8e801db2dc1 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -1443,7 +1443,10 @@ F32 LLSettingsSky::getTotalReflectionProbeAmbiance(F32 cloud_shadow_scale) const
     // without brightening dark/interior spaces
     F32 probe_ambiance = getReflectionProbeAmbiance();
 
-    probe_ambiance += (1.f - probe_ambiance) * getCloudShadow()*cloud_shadow_scale;
+    if (probe_ambiance > 0.f)
+    {
+        probe_ambiance += (1.f - probe_ambiance) * getCloudShadow() * cloud_shadow_scale;
+    }
 
     return probe_ambiance;
 }
diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp
index a609c98d616..f2f269fa63f 100644
--- a/indra/newview/llsettingsvo.cpp
+++ b/indra/newview/llsettingsvo.cpp
@@ -723,8 +723,20 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force)
     }
     else
     {
-        shader->uniform3fv(LLShaderMgr::AMBIENT_LINEAR, linearColor3v(getAmbientColor() / 3.f)); // note magic number 3.f comes from SLIDER_SCALE_SUN_AMBIENT
-        shader->uniform3fv(LLShaderMgr::AMBIENT, LLVector3(ambient.mV));
+        if (psky->getReflectionProbeAmbiance() == 0.f)
+        {
+            LLVector3 ambcol(ambient.mV);
+            F32 cloud_shadow = psky->getCloudShadow();
+            LLVector3 tmpAmbient = ambcol + ((LLVector3::all_one - ambcol) * cloud_shadow * 0.5f);
+
+            shader->uniform3fv(LLShaderMgr::AMBIENT_LINEAR, linearColor3v(tmpAmbient));
+            shader->uniform3fv(LLShaderMgr::AMBIENT, tmpAmbient.mV);
+        }
+        else
+        {
+            shader->uniform3fv(LLShaderMgr::AMBIENT_LINEAR, linearColor3v(getAmbientColor() / 3.f)); // note magic number 3.f comes from SLIDER_SCALE_SUN_AMBIENT
+            shader->uniform3fv(LLShaderMgr::AMBIENT, LLVector3(ambient.mV));
+        }
     }
 
     shader->uniform3fv(LLShaderMgr::BLUE_HORIZON_LINEAR, linearColor3v(getBlueHorizon() / 2.f)); // note magic number of 2.f comes from SLIDER_SCALE_BLUE_HORIZON_DENSITY
-- 
GitLab