From 823172cab99c55b1c26b523d7dd63a99ece9f6cb Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Thu, 28 Mar 2019 14:18:59 -0700
Subject: [PATCH] SL-10831

Make moon brightness env setting affect moon diffuse/ambient color combo so it affects in-world lighting.

Adjust how the moon brightness affects the moon disc texture rendering (washes out less).
---
 indra/llinventory/llsettingssky.cpp                  | 12 +++++++++---
 .../app_settings/shaders/class1/deferred/moonF.glsl  |  2 +-
 .../app_settings/shaders/class1/windlight/moonF.glsl |  2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index a7b87c4d969..0010e626589 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -1295,9 +1295,15 @@ void LLSettingsSky::calculateLightSettings() const
     mSunDiffuse = gammaCorrect(componentMult(sunlight, light_transmittance));
     mSunAmbient = gammaCorrect(componentMult(tmpAmbient, light_transmittance) * 0.5);
 
-    LLColor3 moonlight(0.75, 0.75, 0.92);
-    mMoonDiffuse  = gammaCorrect(componentMult(moonlight, light_transmittance) * 0.25f);
-    mMoonAmbient  = gammaCorrect(componentMult(moonlight, light_transmittance) * 0.125f);
+    F32 moon_brightness = getMoonBrightness();
+
+    LLColor3 moonlight_a(0.66, 0.66, 0.66);
+    LLColor3 moonlight_b(0.66, 0.66, 1.0);
+
+    LLColor3 moonlight = lerp(moonlight_b, moonlight_a, moon_brightness);
+    
+    mMoonDiffuse  = gammaCorrect(componentMult(moonlight, light_transmittance) * moon_brightness * 0.25f);
+    mMoonAmbient  = gammaCorrect(componentMult(moonlight_b, light_transmittance) * 0.0125f);
     mTotalAmbient = mSunAmbient;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl
index d964ce8eee3..e257b668c8c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl
@@ -52,7 +52,7 @@ void main()
 
     // mix factor which blends when sunlight is brighter
     // and shows true moon color at night
-    vec3 luma_weights = vec3(0.2, 0.3, 0.2);
+    vec3 luma_weights = vec3(0.3, 0.5, 0.3);
 
     float mix = 1.0 - dot(normalize(sunlight_color.rgb), luma_weights);
 
diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl
index 947c301110e..c8bbdd109dd 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl
@@ -52,7 +52,7 @@ void main()
 
     // mix factor which blends when sunlight is brighter
     // and shows true moon color at night
-    vec3 luma_weights = vec3(0.2, 0.3, 0.2);
+    vec3 luma_weights = vec3(0.3, 0.5, 0.3);
     float mix = 1.0f - dot(normalize(sunlight_color.rgb), luma_weights);
 
     vec3 exp = vec3(1.0 - mix * moon_brightness) * 2.0 - 1.0;
-- 
GitLab