diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index fecca129053eb65b5fd83232440621f53324e3b4..23b2b003a5967a7e3cc3cb7cb04e3f746fc2558d 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -1249,14 +1249,22 @@ LLColor4 LLSettingsSky::getTotalAmbient() const
 LLColor3 LLSettingsSky::getMoonlightColor() const
 {
     F32 moon_brightness = getIsMoonUp() ? getMoonBrightness() : 0.001f;
-
-    LLColor3 moonlight_a(0.45, 0.45, 0.66);
-    LLColor3 moonlight_b(0.33, 0.33, 1.0);
-
+    LLColor3 moonlight_a(0.9, 0.9, 1.32);
+    LLColor3 moonlight_b(0.66, 0.66, 2.0);
     LLColor3 moonlight = lerp(moonlight_b, moonlight_a, moon_brightness);    
     return moonlight;
 }
 
+void LLSettingsSky::clampColor(LLColor3& color) const
+{
+    F32 max_color = llmax(color.mV[0], color.mV[1], color.mV[2]);
+    if (max_color > 1.f)
+    {
+        color *= 1.f/max_color;
+    }
+    color.clamp();
+}
+
 void LLSettingsSky::calculateLightSettings() const
 {
     // Initialize temp variables
@@ -1282,30 +1290,28 @@ void LLSettingsSky::calculateLightSettings() const
     }
     lighty = llmax(LIMIT, lighty);
     componentMultBy(sunlight, componentExp((light_atten * -1.f) * lighty));
+    componentMultBy(sunlight, light_transmittance);
+    clampColor(sunlight);
 
     //increase ambient when there are more clouds
     LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow;
+    componentMultBy(tmpAmbient, light_transmittance);
+    clampColor(tmpAmbient);
 
     //brightness of surface both sunlight and ambient
-    // reduce range to 0 - 1 before gamma correct to prevent clipping
-    // then restore to full 0 - 3 range before storage
-    //mSunDiffuse = gammaCorrect(componentMult(sunlight,   light_transmittance));
-    //mSunAmbient = gammaCorrect(componentMult(tmpAmbient, light_transmittance));
-
-    mSunDiffuse = componentMult(sunlight,   light_transmittance);
-    mSunAmbient = componentMult(tmpAmbient, light_transmittance);
+    mSunDiffuse = gammaCorrect(sunlight);
+    mSunAmbient = gammaCorrect(tmpAmbient);
 
     F32 moon_brightness = getIsMoonUp() ? getMoonBrightness() : 0.001f;
 
     LLColor3 moonlight = getMoonlightColor();
-    LLColor3 moonlight_b(0.33, 0.33, 1.0); // scotopic ambient value
+    LLColor3 moonlight_b(0.66, 0.66, 1.2); // scotopic ambient value
 
     componentMultBy(moonlight, componentExp((light_atten * -1.f) * lighty));
+    clampColor(moonlight);
 
-    //mMoonDiffuse  = gammaCorrect(componentMult(moonlight, light_transmittance) * moon_brightness);
-    //mMoonAmbient  = gammaCorrect(componentMult(moonlight_b, light_transmittance) * 0.0125f);
-    mMoonDiffuse  = componentMult(moonlight, light_transmittance) * moon_brightness;
-    mMoonAmbient  = componentMult(moonlight_b, light_transmittance) * 0.0125f;
+    mMoonDiffuse  = gammaCorrect(componentMult(moonlight, light_transmittance) * moon_brightness);
+    mMoonAmbient  = gammaCorrect(componentMult(moonlight_b, light_transmittance) * 0.0125f);
 
     mTotalAmbient = mSunAmbient;
 }
diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h
index 92b8a8bd5a19e72dbe7238ce759fb9d22471f9c2..d04209a1a1704f330027ea6eaa2e7defe90076d1 100644
--- a/indra/llinventory/llsettingssky.h
+++ b/indra/llinventory/llsettingssky.h
@@ -346,6 +346,7 @@ class LLSettingsSky: public LLSettingsBase
 
     void        calculateHeavenlyBodyPositions() const;
     void        calculateLightSettings() const;
+    void        clampColor(LLColor3& color) const;
 
     mutable LLVector3   mSunDirection;
     mutable LLVector3   mMoonDirection;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 2b5509400e7be0700b578ca9f7b9ae321a767515..93359e0d4cddbe15074049953e84e692fbbf038d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -102,8 +102,6 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec
         return col;
     }
 
-    dist /= la;
-
     /* clip to projector bounds
      vec4 proj_tc = proj_mat * lp;
 
@@ -117,16 +115,17 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec
         return col;
     }*/
 
-    fa += 1.0;
-	if (dist > 0.0 && la > 0.0 && fa > 0.0)
+	if (dist > 0.0 && la > 0.0)
 	{
+         dist /= la;
+
 		//normalize light vector
 		lv = normalize(lv);
 	
 		//distance attenuation
 		float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
 		dist_atten *= dist_atten;
-        dist_atten *= 2.0f;
+        //dist_atten *= 2.0f;
 
         if (dist_atten <= 0.0)
         {
@@ -177,14 +176,14 @@ void main()
 
 #ifdef USE_DIFFUSE_TEX
     vec4 diffuse_srgb = texture2D(diffuseMap,vary_texcoord0.xy);
-    vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a);
 #endif
 
 #ifdef USE_INDEXED_TEX
-    vec4 diffuse_linear = diffuseLookup(vary_texcoord0.xy);
-    vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a);
+    vec4 diffuse_srgb = diffuseLookup(vary_texcoord0.xy);
 #endif
 
+    vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a);
+
 #ifdef FOR_IMPOSTOR
     vec4 color;
     color.rgb = diffuse_srgb.rgb;
@@ -236,9 +235,7 @@ void main()
     float ambient = da;
     ambient *= 0.5;
     ambient *= ambient;
-
-    float ambient_clamp = getAmbientClamp() + 0.1;
-    ambient = (1.0 - ambient) * ambient_clamp;
+    ambient = (1.0 - ambient);
 
     vec3 sun_contrib = min(final_da, shadow) * sunlit;
 
@@ -268,7 +265,7 @@ vec3 post_atmo = color.rgb;
     // to linear!
     color.rgb = srgb_to_linear(color.rgb);
 
-   #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_srgb.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w);
+   #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_linear.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w);
 
     LIGHT_LOOP(1)
     LIGHT_LOOP(2)
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index c3ca9a6904a56805c6ce92fe07d48987443e8331..470115790973a4b721a8f5f15ba985cbc48758de 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -112,8 +112,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe
         return col;
     }*/
 
-    fa += 1.0;
-	if (dist > 0.0 && la > 0.0 && fa > 0.0)
+	if (dist > 0.0 && la > 0.0)
 	{
 		//normalize light vector
 		lv = normalize(lv);
@@ -121,7 +120,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe
 		//distance attenuation
 		float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
 		dist_atten *= dist_atten;
-        dist_atten *= 2.0f;
+        //dist_atten *= 2.0f;
 
         if (dist_atten <= 0.0)
         {
@@ -328,9 +327,7 @@ void main()
     float ambient = da;
     ambient *= 0.5;
     ambient *= ambient;
-
-    float ambient_clamp = getAmbientClamp() + 0.1;
-    ambient = (1.0 - ambient) * ambient_clamp;
+    ambient = (1.0 - ambient);
 
     vec3 sun_contrib = min(final_da, shadow) * sunlit;
    
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 39d14314cc4b39125234c147eaa4b7c11cd47df4..e07b31b3c1b7ee51f5a55b68eadc5ba82b041159 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -106,10 +106,7 @@ void main()
         float ambient = da;
         ambient *= 0.5;
         ambient *= ambient;
-
         ambient = (1.0 - ambient);
-        float ambient_clamp = getAmbientClamp() + 0.1;
-        ambient *= ambient_clamp;
 
         vec3 sun_contrib = final_da * sunlit;
 
diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
index 55ffbdcc46191ea585c7671294039b98c0df26a8..a702b8d510cc5cdf8b61eb559bff2718488ded4c 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
@@ -138,6 +138,6 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o
 
     //brightness of surface both sunlight and ambient
     sunlit = sunlight.rgb * 0.5;
-    amblit = tmpAmbient.rgb * .25;
+    amblit = tmpAmbient.rgb * .5;
     additive *= vec3(1.0 - temp1);
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 7f83e168bb67087823bef83763b6f7c525659fc8..35018360acb9484e5fb1f83c05e7b10916953d29 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -114,10 +114,7 @@ void main()
         float ambient = da;
         ambient *= 0.5;
         ambient *= ambient;
-
-        float ambient_clamp = getAmbientClamp() + 0.1;
         ambient = (1.0 - ambient);
-        ambient *= ambient_clamp;
 
         vec3 sun_contrib = min(scol, final_da) * sunlit;
 
@@ -161,7 +158,9 @@ vec3 post_diffuse = color.rgb;
                 vec3 sp = sun_contrib*scontrib / 16.0;
                 sp = clamp(sp, vec3(0), vec3(1));
                 bloom += dot(sp, sp) / 6.0;
+#if !defined(SUNLIGHT_KILL)
                 color += sp * spec.rgb;
+#endif
             }
         }
        
@@ -175,7 +174,9 @@ vec3 post_diffuse = color.rgb;
         { //add environmentmap
             vec3 env_vec = env_mat * refnormpersp;
             vec3 reflected_color = textureCube(environmentMap, env_vec).rgb;
+#if !defined(SUNLIGHT_KILL)
             color = mix(color.rgb, reflected_color, envIntensity); 
+#endif
         }
         
 vec3 post_env = color.rgb;
diff --git a/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl
index eca8515212357a5909bbbb79c745751a959adee6..6918ac3b8c73112f8a457f0082965f03837b6441 100644
--- a/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl
+++ b/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl
@@ -35,7 +35,7 @@ vec4 calcLighting(vec3 pos, vec3 norm, vec4 color)
 	vec4 c = sumLights(pos, norm, color);
 
 #if !defined(AMBIENT_KILL)
-    c.rgb += atmosAmbient() * color.rgb * getAmbientClamp();
+    c.rgb += atmosAmbient() * color.rgb * 0.5 * getAmbientClamp();
 #endif
 
     return c;