diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index dac93cee3a82b0e7ada74621e8d484d482b0f50c..1bc576a4ec5a7d4f05cf2b9d4ab9890d0fb5518c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -194,8 +194,10 @@ void main()
 
     vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir;
     float da = dot(norm.xyz, light_dir.xyz);
-          da = clamp(da, 0.0, 1.0);
-          da = pow(da, 1.0 / 1.3);
+
+    float final_da = da;
+          final_da = clamp(final_da, 0.0f, 1.0f);
+		  final_da = pow(final_da, 1.0/1.3);
 
     vec4 color = vec4(0,0,0,0);
 
@@ -205,9 +207,10 @@ void main()
     float ambient = abs(da);
     ambient *= 0.5;
     ambient *= ambient;
+    ambient = max(0.9, ambient); // keeps shadows dark
     ambient = 1.0 - ambient;
 
-    vec3 sun_contrib = min(da, shadow) * sunlit;
+    vec3 sun_contrib = min(final_da, shadow) * sunlit;
 
     color.rgb *= ambient;
     color.rgb += sun_contrib;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index c43b5b22bf0f7a79d7b2605c2e8b555a0bdcf092..4e24e6101845ba6f0fc226a253286d42705d91ce 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -296,16 +296,18 @@ void main()
     vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
 
     float da = dot(norm.xyz, light_dir.xyz);
-    da = clamp(da, 0.0, 1.0);
-    da = pow(da, 1.0 / 1.3);
+
+    float final_da = da;
+          final_da = clamp(final_da, 0.0, 1.0);
+          final_da = pow(final_da, 1.0 / 1.3);
 
     float ambient = abs(da);
     ambient *= 0.5;
     ambient *= ambient;
+    ambient = max(0.9, ambient);
     ambient = 1.0 - ambient;
 
-    float final_da = min(da, shadow);
-    vec3 sun_contrib = final_da * sunlit;
+    vec3 sun_contrib = min(final_da, shadow) * sunlit;
    
     col.rgb = amblit;
     col.rgb *= ambient;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
index 6ff49c7dacb45dbb1ec29371e79cb1a5e635b144..642aff6c4179eef2893f425390ead62e42b5c4ed 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
@@ -51,15 +51,12 @@ float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul,
     stc.xyz /= stc.w;
     stc.z += shadow_bias * bias_mul * 2.0;
     stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here
-    
     float cs = shadow2D(shadowMap, stc.xyz).x;
     float shadow = cs * 4.0;
-    
     shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
     shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
     shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;
     shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;
-                       
     return shadow * 0.125;
 }
 
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 7f1d518dd663640850bd3f443acb729c4ced5bff..92888e0fd209d638b9bce1f087643cb81985f49f 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -94,18 +94,20 @@ void main()
 
     vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;        
 
+    float light_gamma = 1.0/1.3;
     float scol = 1.0;
     vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
 
     float da = dot(normalize(norm.xyz), light_dir.xyz);
-          da = clamp(da, 0.0, 1.0);
-
-    float light_gamma = 1.0/1.3;
-	      da = pow(da, light_gamma);
 
     vec4 diffuse = texture2DRect(diffuseRect, tc);
    
     scol = max(scol_ambocc.r, diffuse.a);
+	//scol = pow(scol, light_gamma);
+
+    float final_da = da;
+          final_da = clamp(final_da, 0.0, 1.0);
+	      final_da = pow(final_da, light_gamma);
 
     vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
     vec3 col;
@@ -123,9 +125,10 @@ void main()
         float ambient = abs(da);
         ambient *= 0.5;
         ambient *= ambient;
+        ambient = max(0.9, ambient);
         ambient = 1.0 - ambient;
 
-        vec3 sun_contrib = min(da,scol) * sunlit;
+        vec3 sun_contrib = min(scol, final_da) * sunlit;
 
         col.rgb = amblit;
         col.rgb *= ambient;