From 1940188e75806ffdd60807017210092b0dbe0dcf Mon Sep 17 00:00:00 2001
From: Henri Beauchamp <sldev@free.fr>
Date: Wed, 7 Feb 2024 21:40:17 +0100
Subject: Confusion between light diffuse and light color in HDR auto-adjust
 mode

While the SUNLIGHT_COLOR uniform is initialized with getSunlightColor() when not
auto-adjusting for HDR, it is overwritten with getSunDiffuse()*auto_adjust_factor
when auto-adjusting, causing very bad lighting discrepancies in the latter mode
(especially when not at midday or midnight).

Let's use getSunlightColor() everywhere, shall we ?...
---
 indra/newview/llsettingsvo.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp
index 7009fb98ab..17405ca864 100644
--- a/indra/newview/llsettingsvo.cpp
+++ b/indra/newview/llsettingsvo.cpp
@@ -718,11 +718,11 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force)
     LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();
 
     // TODO -- make these getters return vec3s
-    LLVector3 sunDiffuse = LLVector3(psky->getSunlightColor().mV);
-    LLVector3 moonDiffuse = LLVector3(psky->getMoonlightColor().mV);
+    LLVector3 sun_light_color = LLVector3(psky->getSunlightColor().mV);
+    LLVector3 moon_light_color = LLVector3(psky->getMoonlightColor().mV);
 
-    shader->uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, sunDiffuse);
-    shader->uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, moonDiffuse);
+    shader->uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, sun_light_color);
+    shader->uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, moon_light_color);
 
     shader->uniform3fv(LLShaderMgr::CLOUD_COLOR, LLVector3(psky->getCloudColor().mV));
 
@@ -766,9 +766,9 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force)
             shader->uniform1f(LLShaderMgr::SKY_HDR_SCALE, auto_adjust_hdr_scale);
             LLColor3 blue_horizon = getBlueHorizon() * auto_adjust_blue_horizon_scale;
             LLColor3 blue_density = getBlueDensity() * auto_adjust_blue_density_scale;
-            LLColor3 sun_diffuse = getSunDiffuse() * auto_adjust_sun_color_scale;
+            sun_light_color = sun_light_color * auto_adjust_sun_color_scale;
             
-            shader->uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, sun_diffuse.mV);
+            shader->uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, sun_light_color.mV);
             shader->uniform3fv(LLShaderMgr::BLUE_DENSITY, blue_density.mV);
             shader->uniform3fv(LLShaderMgr::BLUE_HORIZON, blue_horizon.mV);
 
-- 
cgit v1.2.3