From c0958922c3b3015fd7f17781a79032050b2ed387 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Thu, 30 Mar 2023 18:41:34 -0500
Subject: [PATCH] DRTVWR-559 Auto exposure tuning (fix horizon).

---
 indra/newview/app_settings/shaders/class1/deferred/skyV.glsl  | 2 +-
 .../shaders/class2/windlight/atmosphericsFuncs.glsl           | 4 +++-
 .../app_settings/shaders/class3/deferred/softenLightF.glsl    | 1 -
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
index 62d134188c7..0090155e5cd 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
@@ -91,7 +91,7 @@ void main()
     vary_LightNormPosDot = rel_pos_lightnorm_dot;
 
     // Initialize temp variables
-    vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
+    vec3 sunlight = (sun_up_factor == 1) ? sunlight_color*2.0 : moonlight_color;
     
     // Sunlight attenuation effect (hue and brightness) due to atmosphere
     // this is used later for sunlight modulation at various altitudes
diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl
index 12a99edc344..c2527db218f 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl
@@ -63,7 +63,9 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou
     vec3  rel_pos_norm = normalize(rel_pos);
     float rel_pos_len  = length(rel_pos);
     
+    float scale = sun_up_factor + 1;
     vec3  sunlight     = (sun_up_factor == 1) ? sunlight_color: moonlight_color;
+    sunlight *= scale;
 
     // sunlight attenuation effect (hue and brightness) due to atmosphere
     // this is used later for sunlight modulation at various altitudes
@@ -141,7 +143,7 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou
     
     // fudge sunlit and amblit to get consistent lighting compared to legacy
     // midday before PBR was a thing
-    sunlit = sunlight.rgb;
+    sunlit = sunlight.rgb / scale;
     amblit = tmpAmbient.rgb * 0.25;
 
     additive *= vec3(1.0 - combined_haze);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index b23741e5747..0e3ebd1534b 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -212,7 +212,6 @@ void main()
     {
         //should only be true of WL sky, just port over base color value
         color = srgb_to_linear(texture2D(emissiveRect, tc).rgb);
-        color *= sun_up_factor + 1.0;
     }
     else
     {
-- 
GitLab