From 29b3727b8cc833c664a79a242c9043e6070041e8 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 7 Mar 2023 14:06:01 -0600
Subject: SL-19355 Irradiance rebalance.

---
 indra/llrender/llrender.cpp                                           | 2 +-
 .../app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl      | 4 +++-
 indra/newview/llreflectionmapmanager.cpp                              | 2 +-
 indra/newview/llsettingsvo.cpp                                        | 4 ++--
 4 files changed, 7 insertions(+), 5 deletions(-)

(limited to 'indra')

diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index de74f2700a..5b814f03cb 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -992,7 +992,7 @@ void LLRender::syncLightState()
         shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, LL_NUM_LIGHT_UNITS, diffuse[0].mV);
         shader->uniform3fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV);
         shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_primary[0] ? 1 : 0);
-        shader->uniform3fv(LLShaderMgr::AMBIENT, 1, mAmbientLightColor.mV);
+        //shader->uniform3fv(LLShaderMgr::AMBIENT, 1, mAmbientLightColor.mV);
         shader->uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV);
         shader->uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV);
     }
diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl
index 34ac0c62dc..55e1411be2 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl
@@ -169,7 +169,9 @@ void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, ou
     // multiply by 2 to get same colors as when the "scaleSoftClip" implementation was doubling color values
     // (allows for mixing of light sources other than sunlight e.g. reflection probes)
     sunlit *= 2.0;
-    amblit *= 2.0;
+
+    // squash ambient to approximate whatever weirdness legacy atmospherics were doing
+    amblit = ambient_color * 0.5;
 
     amblit *= ambientLighting(norm, light_dir);
     amblit = srgb_to_linear(amblit);
diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp
index 61d8756490..90c4436a04 100644
--- a/indra/newview/llreflectionmapmanager.cpp
+++ b/indra/newview/llreflectionmapmanager.cpp
@@ -815,7 +815,7 @@ void LLReflectionMapManager::updateUniforms()
 
     F32 ambscale = gCubeSnapshot && !isRadiancePass() ? 0.f : 1.f;
     F32 radscale = gCubeSnapshot && !isRadiancePass() ? 0.5f : 1.f;
-
+    
     for (auto* refmap : mReflectionMaps)
     {
         if (refmap == nullptr)
diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp
index ac5bde7b9b..a609c98d61 100644
--- a/indra/newview/llsettingsvo.cpp
+++ b/indra/newview/llsettingsvo.cpp
@@ -675,7 +675,7 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force)
     LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
     LLVector3 light_direction = LLVector3(LLEnvironment::instance().getClampedLightNorm().mV);
 
-    bool radiance_pass = gCubeSnapshot && !gPipeline.mReflectionMapManager.isRadiancePass();
+    bool irradiance_pass = gCubeSnapshot && !gPipeline.mReflectionMapManager.isRadiancePass();
 
     LLShaderUniforms* shader = &((LLShaderUniforms*)ptarget)[LLGLSLShader::SG_DEFAULT];
 	{        
@@ -716,7 +716,7 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force)
 
     LLColor3 ambient(getTotalAmbient());
 
-    if (radiance_pass)
+    if (irradiance_pass)
     { // during an irradiance map update, disable ambient lighting (direct lighting only) and desaturate sky color (avoid tinting the world blue)
         shader->uniform3fv(LLShaderMgr::AMBIENT_LINEAR, LLVector3::zero.mV);
         shader->uniform3fv(LLShaderMgr::AMBIENT, LLVector3::zero.mV);
-- 
cgit v1.2.3