diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index a0d81e6d995e9c33d6cd14320f818046d2c1c2cb..41e888218157fefb8c2b38950e50412916f3c4d9 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -1180,29 +1180,34 @@ void LLSettingsSky::setHazeHorizon(F32 val)
     setDirtyFlag(true);
 }
 
+// Get total from rayleigh and mie density values for normalization
+LLColor3 LLSettingsSky::getTotalDensity() const
+{
+    LLColor3    blue_density = getBlueDensity();
+    F32         haze_density = getHazeDensity();
+    LLColor3 total_density = blue_density + smear(haze_density);
+    return total_density;
+}
+
 // Sunlight attenuation effect (hue and brightness) due to atmosphere
 // this is used later for sunlight modulation at various altitudes
 LLColor3 LLSettingsSky::getLightAttenuation(F32 distance) const
 {
-// LEGACY_ATMOSPHERICS
-    LLColor3    blue_density = getBlueDensity();
-    F32         haze_density = getHazeDensity();
     F32         density_multiplier = getDensityMultiplier();
-    LLColor3    density = (blue_density * 1.0 + smear(haze_density * 0.25f));
-    LLColor3    light_atten = density * density_multiplier * distance;
+    LLColor3    blue_density       = getBlueDensity();
+    F32         haze_density       = getHazeDensity();
+    // Approximate line integral over requested distance
+    LLColor3    light_atten = (blue_density * 1.0 + smear(haze_density * 0.25f)) * density_multiplier * distance;
     return light_atten;
 }
 
 LLColor3 LLSettingsSky::getLightTransmittance() const
 {
-// LEGACY_ATMOSPHERICS
-    LLColor3    blue_density = getBlueDensity();
-    F32         haze_density = getHazeDensity();
-    F32         density_multiplier = getDensityMultiplier();
-    LLColor3 temp1 = blue_density + smear(haze_density);
-    // Transparency (-> temp1)
-    temp1 = componentExp((temp1 * -1.f) * density_multiplier);
-    return temp1;
+    LLColor3 total_density      = getTotalDensity();
+    F32      density_multiplier = getDensityMultiplier();
+    // Transparency (-> density) from Beer's law
+    LLColor3 transmittance = componentExp(total_density * -density_multiplier);
+    return transmittance;
 }
 
 LLColor3 LLSettingsSky::gammaCorrect(const LLColor3& in) const
@@ -1262,18 +1267,19 @@ void LLSettingsSky::calculateLightSettings() const
 {
     // Initialize temp variables
     LLColor3    sunlight = getSunlightColor();
-    LLColor3    ambient = getAmbientColor();
+    LLColor3    ambient  = getAmbientColor();
+
     F32         cloud_shadow = getCloudShadow();
     LLVector3   lightnorm = getLightDirection();
 
     // Sunlight attenuation effect (hue and brightness) due to atmosphere
     // this is used later for sunlight modulation at various altitudes
-    F32      max_y = getMaxY();
-    LLColor3 light_atten = getLightAttenuation(max_y);
-    LLColor3 light_transmittance = getLightTransmittance();
+    F32         max_y               = getMaxY();
+    LLColor3    light_atten         = getLightAttenuation(max_y);
+    LLColor3    light_transmittance = getLightTransmittance();
 
     // and vary_sunlight will work properly with moon light
-    F32 lighty = lightnorm[1];
+    F32 lighty = lightnorm[2];
     if(lighty > 0.001f)
     {
         lighty = 1.f / lighty;
@@ -1282,22 +1288,23 @@ void LLSettingsSky::calculateLightSettings() const
     componentMultBy(sunlight, componentExp((light_atten * -1.f) * lighty));
 
     //increase ambient when there are more clouds
-    LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow * 0.5f;
+    LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow;
 
     //brightness of surface both sunlight and ambient
-    mSunDiffuse = gammaCorrect(componentMult(sunlight, light_transmittance));
-    mSunAmbient = gammaCorrect(componentMult(tmpAmbient, light_transmittance) * 0.5);
+    mSunDiffuse = gammaCorrect(componentMult(sunlight,   light_transmittance));
+    mSunAmbient = gammaCorrect(componentMult(tmpAmbient, light_transmittance));
 
     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);
-    
+    LLColor3 moonlight = lerp(moonlight_b, moonlight_a, moon_brightness);    
+    componentMultBy(moonlight, componentExp((light_atten * -1.f) * lighty));
+
     mMoonDiffuse  = gammaCorrect(componentMult(moonlight, light_transmittance) * moon_brightness * 0.25f);
     mMoonAmbient  = gammaCorrect(componentMult(moonlight_b, light_transmittance) * 0.0125f);
-    mTotalAmbient = mSunAmbient;
+    mTotalAmbient = mSunAmbient + mMoonAmbient;
 }
 
 LLUUID LLSettingsSky::GetDefaultAssetId()
diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h
index d585eeddfa1defa46995baa8af93590d2ab8acaa..ef2a6740f0776948f34b62247a86938c054999e2 100644
--- a/indra/llinventory/llsettingssky.h
+++ b/indra/llinventory/llsettingssky.h
@@ -252,6 +252,7 @@ class LLSettingsSky: public LLSettingsBase
 
     LLColor3 getLightAttenuation(F32 distance) const;
     LLColor3 getLightTransmittance() const;
+    LLColor3 getTotalDensity() const;
     LLColor3 gammaCorrect(const LLColor3& in) const;
 
     LLColor3 getBlueDensity() const;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
index 6cc436c83731767b13ef65bb67e83acea799a8b1..61fd43f1eebf265f2845ed96063b6ec539ba2f91 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
@@ -103,7 +103,7 @@ void main()
 	vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
 	vec4 light_atten;
 
-    float dens_mul = density_multiplier * 0.5;
+    float dens_mul = density_multiplier;
 
 	// 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/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
index 7d56742d6f34c15bfdca64f539d204d808034c19..bee8e2dab5fe5a9961d7828b9627da85cfb2f933 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
@@ -87,7 +87,7 @@ void main()
 	vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
 	vec4 light_atten;
 
-    float dens_mul = density_multiplier * 0.5;
+    float dens_mul = density_multiplier;
 
 	// 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/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
index 3d05912f49f1f2203a93ea4779911bbb3c6dfc38..fc495622355ee9364536ef25b0d3df9886cc5550 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
@@ -62,8 +62,8 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o
     vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
     vec4 light_atten;
 
-    float dens_mul = density_multiplier * 0.5; // get back to original pre-EEP range...
-    float dist_mul = distance_multiplier * 0.1; // get back to original pre-EEP range...
+    float dens_mul = density_multiplier;
+    float dist_mul = distance_multiplier * 0.1;
 
     //sunlight attenuation effect (hue and brightness) due to atmosphere
     //this is used later for sunlight modulation at various altitudes
@@ -76,7 +76,7 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o
     haze_weight = vec4(haze_density) / temp1;
 
     //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain)
-    temp2.y = max(0.0, tmpLightnorm.y);
+    temp2.y = max(0.0, tmpLightnorm.z);
     if (temp2.y > 0.001f)
     {
         temp2.y = 1. / temp2.y;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl
index ea926ab5f187c00f01773c89aa1a216ecd2fdbf5..a8eb7102edbef58be362fd4056a3fd3d3f921fc5 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl
@@ -117,7 +117,7 @@ void main()
     vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
     vec4 light_atten;
 
-    float dens_mul = density_multiplier * 0.5;
+    float dens_mul = density_multiplier;
 
     // 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/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
index fcfe5bbba0cd9c451f6915259e44e7f18d2d4093..64156bd3bf979887569b21af394ca6348456e469 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
@@ -103,7 +103,7 @@ void main()
     vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
     vec4 light_atten;
 
-    float dens_mul = density_multiplier * 0.5;
+    float dens_mul = density_multiplier;
 
     // 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/skyV.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
index a253bb72d52d2a5575a775055eaf6a964e0f3542..6d6b3dafa72ed58bbe3a6575166cd65fbcbb6321 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
@@ -87,7 +87,7 @@ void main()
 	vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
 	vec4 light_atten;
 
-    float dens_mul = density_multiplier * 0.5;
+    float dens_mul = density_multiplier;
 
 	// Sunlight attenuation effect (hue and brightness) due to atmosphere
 	// this is used later for sunlight modulation at various altitudes