diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl
index 3557c0766e9babcabb640370a962236dfde93aa4..c66f3f62b2186c9d9b962c516e75e6ae7571e422 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl
@@ -40,17 +40,21 @@ uniform sampler2D diffuseMap;
 uniform sampler2D altDiffuseMap;
 uniform float blend_factor; // interp factor between sunDisc A/B
 VARYING vec2 vary_texcoord0;
+VARYING float sun_fade;
 
 void main() 
 {
-	vec4 sunDiscA = texture2D(diffuseMap, vary_texcoord0.xy);
-	vec4 sunDiscB = texture2D(altDiffuseMap, vary_texcoord0.xy);
+    vec4 sunDiscA = texture2D(diffuseMap, vary_texcoord0.xy);
+    vec4 sunDiscB = texture2D(altDiffuseMap, vary_texcoord0.xy);
     vec4 c     = mix(sunDiscA, sunDiscB, blend_factor);
     c.rgb = clamp(c.rgb, vec3(0), vec3(1));
-	c.rgb = pow(c.rgb, vec3(0.7f));
-	c.rgb = fullbrightAtmosTransport(c.rgb);
+    c.rgb = pow(c.rgb, vec3(0.7f));
+    c.rgb = fullbrightAtmosTransport(c.rgb);
     c.rgb = fullbrightScaleSoftClip(c.rgb);
-	frag_data[0] = c;
+
+    c.a *= sun_fade;
+
+    frag_data[0] = c;
     frag_data[1] = vec4(0.0f);
     frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunDiscV.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunDiscV.glsl
index c67ed8e6d9a8e093412dca2b4a99999e1c8dd9d0..0d117c6bc7f467589f14d12e2662ed9de8a4ce04 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunDiscV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunDiscV.glsl
@@ -31,18 +31,22 @@ ATTRIBUTE vec3 position;
 ATTRIBUTE vec2 texcoord0;
 
 VARYING vec2 vary_texcoord0;
+VARYING float sun_fade;
 
 void calcAtmospherics(vec3 eye_pos);
 
 void main()
 {
-	//transform vertex
-	vec4 vert = vec4(position.xyz - vec3(0, 0, 50), 1.0);
-	vec4 pos  = modelview_projection_matrix*vert;
+    //transform vertex
+    vec3 offset = vec3(0, 0, 50);
+    vec4 vert = vec4(position.xyz - offset, 1.0);
+    vec4 pos  = modelview_projection_matrix*vert;
 
-	gl_Position = pos;
-	
+    sun_fade = smoothstep(0.3, 1.0, (position.z + 50) / 512.0f);
+
+    gl_Position = pos;
+    
     calcAtmospherics(pos.xyz);
 
-	vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
+    vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
 }
diff --git a/indra/newview/app_settings/shaders/class1/windlight/sunDiscF.glsl b/indra/newview/app_settings/shaders/class1/windlight/sunDiscF.glsl
index 3f2375ee4da5dde08718a15222575002758e9d51..668379164d97102298c659d5f7267859b7d96347 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/sunDiscF.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/sunDiscF.glsl
@@ -40,15 +40,18 @@ uniform sampler2D diffuseMap;
 uniform sampler2D altDiffuseMap;
 uniform float blend_factor; // interp factor between sun A/B
 VARYING vec2 vary_texcoord0;
+VARYING float sun_fade;
 
 void main() 
 {
-	vec4 sunA = texture2D(diffuseMap, vary_texcoord0.xy);
-	vec4 sunB = texture2D(altDiffuseMap, vary_texcoord0.xy);
+    vec4 sunA = texture2D(diffuseMap, vary_texcoord0.xy);
+    vec4 sunB = texture2D(altDiffuseMap, vary_texcoord0.xy);
     vec4 c     = mix(sunA, sunB, blend_factor);
+    c.a *= sun_fade;
+
     c.rgb = pow(c.rgb, vec3(0.7f));
-	c.rgb = fullbrightAtmosTransport(c.rgb);
+    c.rgb = fullbrightAtmosTransport(c.rgb);
     c.rgb = fullbrightScaleSoftClip(c.rgb);
-	frag_color = c;
+    frag_color = c;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/windlight/sunDiscV.glsl b/indra/newview/app_settings/shaders/class1/windlight/sunDiscV.glsl
index dd33a4be6094eb89a6d9295e5ae6bcd41cef5c4c..1fa32c3f3b8c7a8b9c3a538e05a425f68c6a881f 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/sunDiscV.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/sunDiscV.glsl
@@ -31,18 +31,20 @@ ATTRIBUTE vec3 position;
 ATTRIBUTE vec2 texcoord0;
 
 VARYING vec2 vary_texcoord0;
+VARYING float sun_fade;
 
 void calcAtmospherics(vec3 eye_pos);
 
 void main()
 {
-	//transform vertex
-	vec4 vert = vec4(position.xyz - vec3(0, 0, 50), 1.0);
-	vec4 pos = modelview_projection_matrix*vert;
+    //transform vertex
+    vec4 vert = vec4(position.xyz, 1.0);
+    vec4 pos = modelview_projection_matrix*vert;
 
-	gl_Position = pos;
-	
+    sun_fade = smoothstep(0.3, 1.0, (position.z + 50) / 512.0f);
+    gl_Position = pos;
+    
     calcAtmospherics(pos.xyz);
 
-	vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
+    vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
 }
diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl
index 8c1a7c628153c9260ed9b98ad7ec0be73c1acb66..5ccf786fce66f2490204257904b5889d30d76ca4 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl
@@ -62,8 +62,8 @@ void calcAtmospherics(vec3 inPositionEye) {
     setPositionEye(P);
     
     //(TERRAIN) limit altitude
-    if (P.y > max_y) P *= (max_y / P.y);
-    if (P.y < -max_y) P *= (-max_y / P.y);
+    //if (P.y > max_y) P *= (max_y / P.y);
+    //if (P.y < -max_y) P *= (-max_y / P.y);
 
     vec3 tmpLightnorm = lightnorm.xyz;
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 9d8f98688f778894f0fd3b494006f2b77cdb88fa..9b89af20d275a5be08a25e58067d2c083d98af45 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -117,10 +117,6 @@
 
 #include "llenvironment.h"
 
-#if LL_WINDOWS
-#pragma optimize("", off)
-#endif
-
 #ifdef _DEBUG
 // Debug indices is disabled for now for debug performance - djs 4/24/02
 //#define DEBUG_INDICES
diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml
index e63b7e41b437862dfe68eb760d708b1fe70826a8..2aab41c5a02970d730d35dccc6329a575e0a519a 100644
--- a/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml
+++ b/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml
@@ -78,7 +78,7 @@
                     decimal_digits="2"
                     follows="left|top"
                     height="16"
-                    increment="0.25"
+                    increment="0.01"
                     initial_value="0"
                     layout="topleft"
                     left_delta="5"
@@ -254,7 +254,7 @@
                             decimal_digits="2"
                             follows="left|top"
                             height="16"
-                            increment="0.25"
+                            increment="0.01"
                             initial_value="0"
                             layout="topleft"
                             left_delta="5"