diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 07b0f2a98a83befb1195306b984de7585de24603..5e3c767460ff9e9ea7e50d33b63269f57de51f8b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -84,11 +84,8 @@ uniform vec3 light_diffuse[8];
 vec4 applyWaterFogView(vec3 pos, vec4 color);
 #endif
 
-vec3 srgb_to_linear(vec3 cs);
-vec3 linear_to_srgb(vec3 cl);
 vec2 encode_normal (vec3 n);
 vec3 decode_normal (vec2 enc);
-
 vec3 scaleSoftClip(vec3 l);
 vec3 atmosFragAmbient(vec3 light, vec3 sunlit);
 vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten);
@@ -162,7 +159,8 @@ void main()
 	frag *= screen_res;
 	
 	vec4 pos = vec4(vary_position, 1.0);
-	
+	vec3 norm = vary_norm;
+
 	float shadow = 1.0;
 
 #if HAS_SHADOW
@@ -265,17 +263,10 @@ void main()
 	float final_alpha = diff.a;
 #endif
 
-
-	vec4 gamma_diff = diff;	
-	diff.rgb = srgb_to_linear(diff.rgb);
-
-	vec3 norm = vary_norm; 
-
-        vec3 sunlit;
-        vec3 amblit;
-        vec3 additive;
-        vec3 atten;
-
+    vec3 sunlit;
+    vec3 amblit;
+    vec3 additive;
+    vec3 atten;
 	calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten);
 
 	vec2 abnormal	= encode_normal(norm.xyz);
@@ -287,7 +278,7 @@ void main()
     float final_da = max(sun_da, moon_da);
           final_da = min(final_da, shadow);
           final_da = clamp(final_da, 0.0f, 1.0f);
-	  final_da = pow(final_da, 1.0/1.3);
+	  final_da = pow(final_da, display_gamma);
 
 	vec4 color = vec4(0,0,0,0);
 
@@ -300,8 +291,8 @@ void main()
 	ambient = (1.0-ambient);
 
 	color.rgb *= ambient;
-	color.rgb += atmosFragAffectDirectionalLight(final_da, sunlit);
-	color.rgb *= gamma_diff.rgb;
+	color.rgb += (final_da * sunlit);
+	color.rgb *= diff.rgb;
 
 	//color.rgb = mix(diff.rgb, color.rgb, final_alpha);
 	
@@ -310,8 +301,6 @@ void main()
 
 	vec4 light = vec4(0,0,0,0);
 
-	color.rgb = srgb_to_linear(color.rgb);
-	
    #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z);
 
 	LIGHT_LOOP(1)
@@ -326,10 +315,6 @@ void main()
 	//
 	color.rgb += light.rgb;
 
-	// straight to display gamma, we're post-deferred
-	//
-	color.rgb = linear_to_srgb(color.rgb);
-
 #ifdef WATER_FOG
 	color = applyWaterFogView(pos.xyz, color);
 #endif
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
index 0e21e5925dc2375e5b7226b272f873abfd308d83..2db737a42799a916345b06b8061b975c7b16b7e5 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
@@ -45,9 +45,6 @@ VARYING vec2 vary_texcoord0;
 vec4 applyWaterFogView(vec3 pos, vec4 color);
 #endif
 
-vec3 srgb_to_linear(vec3 cs);
-vec3 linear_to_srgb(vec3 cl);
-
 vec3 fullbrightAtmosTransportDeferred(vec3 light)
 {
 	return light;
@@ -81,12 +78,9 @@ void main()
 #endif
 
 	color.rgb *= vertex_color.rgb;
-	color.rgb = srgb_to_linear(color.rgb);
 	color.rgb = fullbrightAtmosTransportDeferred(color.rgb);
 	color.rgb = fullbrightScaleSoftClipDeferred(color.rgb);
 	
-	color.rgb = linear_to_srgb(color.rgb);
-
 #ifdef WATER_FOG
 	vec3 pos = vary_position;
 	vec4 fogged = applyWaterFogView(pos, vec4(color.rgb, final_alpha));
diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
index 6ba16b169ce8b82f1c44381aa8805535acf64b92..d29e8a9423ab73f3b058c0a323251cfe3499bd04 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
@@ -40,8 +40,6 @@ uniform sampler2D specularMap;
 
 VARYING vec2 vary_texcoord0;
 
-vec3 linear_to_srgb(vec3 cl);
-
 void main() 
 {
 	vec4 col = texture2D(diffuseMap, vary_texcoord0.xy);
@@ -54,8 +52,6 @@ void main()
 	vec4 norm = texture2D(normalMap,   vary_texcoord0.xy);
 	vec4 spec = texture2D(specularMap, vary_texcoord0.xy);
 
-	col.rgb = linear_to_srgb(col.rgb);
-
 	frag_data[0] = vec4(col.rgb, 0.0);
 	frag_data[1] = spec;
 	frag_data[2] = vec4(norm.xy,0,0);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index 7d5ae7c2e741d7e0df9b1a107a32584e7a29f24d..211bedee593ca5f8b9aa66a4129b75887bc5149f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -37,10 +37,6 @@ uniform float display_gamma;
 vec4 applyWaterFogView(vec3 pos, vec4 color);
 #endif
 
-vec3 srgb_to_linear(vec3 cs);
-vec3 linear_to_srgb(vec3 cl);
-
-vec3 atmosFragAmbient(vec3 l, vec3 ambient);
 vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten);
 vec3 scaleSoftClipFrag(vec3 l);
 
@@ -234,6 +230,8 @@ vec3 decode_normal (vec2 enc);
 
 void main() 
 {
+    vec2 pos_screen = vary_texcoord0.xy;
+
 	vec4 diffcol = texture2D(diffuseMap, vary_texcoord0.xy);
 	diffcol.rgb *= vertex_color.rgb;
 
@@ -246,7 +244,6 @@ void main()
 
 #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
 	vec3 gamma_diff = diffcol.rgb;
-	diffcol.rgb = srgb_to_linear(diffcol.rgb);
 #endif
 
 #if HAS_SPECULAR_MAP
@@ -390,9 +387,9 @@ void main()
           //final_da = max(final_da, diffuse.a);
           final_da = max(final_da, 0.0f);
 		  final_da = min(final_da, 1.0f);
-		  final_da = pow(final_da, 1.0/1.3);
+		  final_da = pow(final_da, display_gamma);
 
-	col.rgb = atmosFragAmbient(col, amblit);
+	col.rgb = (col * 0.5) + amblit;
 	
 	float ambient = min(abs(final_da), 1.0);
 	ambient *= 0.5;
@@ -446,14 +443,7 @@ void main()
 		glare += cur_glare;
 	}
 
-	//col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a);
-	//col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col),  diffuse.a);
-
 	col = atmosFragLighting(col, additive, atten);
-	col = scaleSoftClipFrag(col);
-
-	//convert to linear space before adding local lights
-	col = srgb_to_linear(col);
 
 	vec3 npos = normalize(-pos.xyz);
 			
@@ -474,8 +464,7 @@ void main()
 	glare = min(glare, 1.0);
 	float al = max(diffcol.a,glare)*vertex_color.a;
 
-	//convert to gamma space for display on screen
-	col.rgb = linear_to_srgb(col.rgb);
+	col = scaleSoftClipFrag(col);
 
 #ifdef WATER_FOG
 	vec4 temp = applyWaterFogView(pos, vec4(col.rgb, al));
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index 1d75322b4cef711f183f056875def7ed959fad13..b3dcd90d9825bd9cc46b6287baf00b84bbbf5f6f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -73,13 +73,10 @@ uniform vec2 screen_res;
 uniform mat4 inv_proj;
 
 vec3 decode_normal (vec2 enc);
-vec3 srgb_to_linear(vec3 cs);
-vec3 linear_to_srgb(vec3 cl);
 
 vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
 {
 	vec4 ret = texture2DLod(projectionMap, tc, lod);
-	ret.rgb = srgb_to_linear(ret.rgb);
 	
 	vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
 	
@@ -99,7 +96,6 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
 vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
 {
 	vec4 ret = texture2DLod(projectionMap, tc, lod);
-	ret.rgb = srgb_to_linear(ret.rgb);
 	
 	vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
 	
@@ -117,7 +113,6 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
 vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
 {
 	vec4 ret = texture2DLod(projectionMap, tc, lod);
-	ret.rgb = srgb_to_linear(ret.rgb);
 	
 	vec2 dist = tc-vec2(0.5);
 	
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
index 87914696755e86df3846282155cf9cf4e2efdd30..0b943d2527126c6734927b4d8953d6ecdc2b09a4 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
@@ -40,12 +40,10 @@ VARYING vec2 vary_fragcoord;
 
 uniform float display_gamma;
 
-vec3 linear_to_srgb(vec3 cl);
-
 void main() 
 {
-	vec4 diff = texture2DRect(diffuseRect, vary_fragcoord);
+    vec4 diff = texture2DRect(diffuseRect, vary_fragcoord);
     diff.rgb = pow(diff.rgb, vec3(display_gamma));
-	frag_color = diff;
+    frag_color = diff;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 41eb06126b255338da808f24c77571307855ccf8..2ba766a0c49b13e801920da2a85844bd883c96ce 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -66,10 +66,7 @@ uniform vec2 screen_res;
 vec4 applyWaterFogView(vec3 pos, vec4 color);
 #endif
 
-vec3 srgb_to_linear(vec3 cs);
-vec3 linear_to_srgb(vec3 cl);
 vec3 decode_normal (vec2 enc);
-
 vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten);
 vec3 fullbrightAtmosTransportFrag(vec3 l, vec3 additive, vec3 atten);
 void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten);
@@ -114,13 +111,10 @@ void main()
 
     vec4 diffuse = texture2DRect(diffuseRect, tc);
 
-    //convert to gamma space
-    //diffuse.rgb = linear_to_srgb(diffuse.rgb);
-
-    vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
-    vec3 col;
-    float bloom = 0.0;
-    {
+	vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
+	vec3 col;
+	float bloom = 0.0;
+	{
         vec3 sunlit;
         vec3 amblit;
         vec3 additive;
@@ -168,18 +162,14 @@ void main()
             col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a);
         }
 
-        #ifdef WATER_FOG
-            vec4 fogged = applyWaterFogView(pos.xyz,vec4(col, bloom));
-            col = fogged.rgb;
-            bloom = fogged.a;
-        #endif
-
-        //col = srgb_to_linear(col);
-        //col = vec3(1,0,1);
-        //col.g = envIntensity;
-    }
+		#ifdef WATER_FOG
+			vec4 fogged = applyWaterFogView(pos.xyz,vec4(col, bloom));
+			col = fogged.rgb;
+			bloom = fogged.a;
+		#endif
+	}
 
-    frag_color.rgb = col.rgb;
-    frag_color.a = bloom;
+	frag_color.rgb = col.rgb;
+	frag_color.a = bloom;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index 2b6428963dff7278d5f072cade24a628c3b2dbd1..1abdd4af332c84ae98c70a2f87e9204ab32929de 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -71,18 +71,10 @@ uniform vec2 screen_res;
 uniform mat4 inv_proj;
 
 vec3 decode_normal (vec2 enc);
-vec3 srgb_to_linear(vec3 cs);
-vec3 linear_to_srgb(vec3 cl);
-
-vec4 correctWithGamma(vec4 col)
-{
-	return vec4(srgb_to_linear(col.rgb), col.a);
-}
 
 vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
 {
 	vec4 ret = texture2DLod(projectionMap, tc, lod);
-	ret.rgb = srgb_to_linear(ret.rgb);
 	
 	vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
 	
@@ -102,7 +94,6 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
 vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
 {
 	vec4 ret = texture2DLod(projectionMap, tc, lod);
-	ret = correctWithGamma(ret);
 	
 	vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
 	
@@ -120,7 +111,6 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
 vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
 {
 	vec4 ret = texture2DLod(projectionMap, tc, lod);
-	ret = correctWithGamma(ret);
 	
 	vec2 dist = tc-vec2(0.5);
 	
diff --git a/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl b/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl
deleted file mode 100644
index bc3324f543845d86bcfa74e86edac1749cc4a079..0000000000000000000000000000000000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/srgb.glsl
+++ /dev/null
@@ -1,61 +0,0 @@
-/** 
- * @file srgb.glsl
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2007, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-vec3 rgb2hsv(vec3 c)
-{
-    vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
-    vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
-    vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
-
-    float d = q.x - min(q.w, q.y);
-    float e = 1.0e-10;
-    return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
-}
-
-vec3 hsv2rgb(vec3 c)
-{
-    vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
-    vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
-    return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
-}
-
-vec3 srgb_to_linear(vec3 cs)
-{
-	vec3 low_range = cs / vec3(12.92);
-	vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4));
-
-	bvec3 lte = lessThanEqual(cs,vec3(0.04045));
-	return mix(high_range, low_range, lte);
-}
-
-vec3 linear_to_srgb(vec3 cl)
-{
-	cl = clamp(cl, vec3(0), vec3(1));
-	vec3 low_range  = cl * 12.92;
-	vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055;
-
-	bvec3 lt = lessThan(cl,vec3(0.0031308));
-	return mix(high_range, low_range, lt);
-}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl
index db1eab23fb2fb749b48f5c74ab9f0c828093c42e..e95a688e1fc75f42ec61f365ce0a99859a6aaca9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/underWaterF.glsl
@@ -58,9 +58,6 @@ VARYING vec4 refCoord;
 VARYING vec4 littleWave;
 VARYING vec4 view;
 
-vec3 srgb_to_linear(vec3 cs);
-vec3 linear_to_srgb(vec3 cl);
-
 vec2 encode_normal(vec3 n);
 
 vec4 applyWaterFog(vec4 color, vec3 viewVec)
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 69543b93eadf19163ae4b6e43ed56f58b003a7a7..9da25485863d3431081b2efc7b4c417954b4b87b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -62,7 +62,6 @@ VARYING vec4 littleWave;
 VARYING vec4 view;
 VARYING vec4 vary_position;
 
-vec3 srgb_to_linear(vec3 cs);
 vec2 encode_normal(vec3 n);
 vec3 scaleSoftClipFrag(vec3 l);
 
diff --git a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl
index f98b3a5edff3d6321ba7baa46c5ed18bc28b7706..4a8b892c3ae99a5fd3aa313f419bf72bbb2f4d7e 100644
--- a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl
@@ -64,3 +64,21 @@ vec3 ColorFromRadiance(vec3 radiance)
 {
     return vec3(1.0) - exp(-radiance * 0.0001);
 }
+
+vec3 rgb2hsv(vec3 c)
+{
+    vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
+    vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
+    vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
+
+    float d = q.x - min(q.w, q.y);
+    float e = 1.0e-10;
+    return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
+}
+
+vec3 hsv2rgb(vec3 c)
+{
+    vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
+    vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
+    return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
+}
diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl
index 8b7c4f2ecfbf5566fb8a8fc7d0d99e6b17b1bd3f..4f0e2a6cb6b7bd37aa13f080ef0a33ba1a5d7ef8 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsF.glsl
@@ -1,5 +1,5 @@
 /** 
- * @file atmosphericsF.glsl
+ * @file class1\windlight\atmosphericsF.glsl
  *
  * $LicenseInfo:firstyear=2005&license=viewerlgpl$
  * Second Life Viewer Source Code
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 864ba4859da93420f5a1ff4e6a4cf1ff56eaa094..0a8981a102f3d1b3c3a00b1e76c6142734523b5f 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -71,19 +71,11 @@ uniform vec2 screen_res;
 
 uniform mat4 inv_proj;
 
-vec3 srgb_to_linear(vec3 cs);
-vec3 linear_to_srgb(vec3 cl);
 vec3 decode_normal (vec2 enc);
 
-vec4 correctWithGamma(vec4 col)
-{
-	return vec4(srgb_to_linear(col.rgb), col.a);
-}
-
 vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
 {
 	vec4 ret = texture2DLod(projectionMap, tc, lod);
-	ret.rgb = srgb_to_linear(ret.rgb);
 	
 	vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
 	
@@ -103,7 +95,6 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
 vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
 {
 	vec4 ret = texture2DLod(projectionMap, tc, lod);
-	ret = correctWithGamma(ret);
 
 	vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
 	
@@ -121,7 +112,6 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
 vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
 {
 	vec4 ret = texture2DLod(projectionMap, tc, lod);
-	ret = correctWithGamma(ret);
 
 	vec2 dist = tc-vec2(0.5);
 	
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 184ac13b275f464460e9ff5138dd5f03d50efdba..9de2741725e6e7f8b2f11fd2b08853a2197b3818 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -74,8 +74,6 @@ VARYING vec2 vary_fragcoord;
 uniform mat4 inv_proj;
 uniform vec2 screen_res;
 
-vec3 srgb_to_linear(vec3 cs);
-vec3 linear_to_srgb(vec3 cl);
 vec3 decode_normal (vec2 enc);
 
 void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten);
@@ -124,13 +122,10 @@ void main()
     float da = max(da_sun, da_moon);
           da = clamp(da, 0.0, 1.0);
 
-    da = pow(da, global_gamma);
-
-    vec4 diffuse = texture2DRect(diffuseRect, tc);
-
-    //convert to gamma space
-	//diffuse.rgb = linear_to_srgb(diffuse.rgb);
+	da = pow(da, global_gamma);
 
+	vec4 diffuse = texture2DRect(diffuseRect, tc);
+	
     vec3 col;
     float bloom = 0.0;
     {
@@ -195,9 +190,6 @@ void main()
             col = fogged.rgb;
             bloom = fogged.a;
         #endif
-
-        //col = srgb_to_linear(col);
-
     }
     frag_color.rgb = col;
     frag_color.a = bloom;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
index c840d727843a95a9f2049dcf827eccb93d6519f3..8b8b338f6851ffbf916ec28a3399b67b3c6e4b5f 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
@@ -36,7 +36,5 @@ void main()
 	//transform vertex
 	vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
 	gl_Position = pos; 
-	
-	
 	vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index a7da140b31c25a6188c4f3ac18217d609c45c70f..d97bd936d97453a9e04ca87910f32cc7a63b0d77 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -72,18 +72,10 @@ uniform vec2 screen_res;
 uniform mat4 inv_proj;
 
 vec3 decode_normal (vec2 enc);
-vec3 srgb_to_linear(vec3 cs);
-vec3 linear_to_srgb(vec3 cl);
-
-vec4 correctWithGamma(vec4 col)
-{
-	return vec4(srgb_to_linear(col.rgb), col.a);
-}
 
 vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
 {
 	vec4 ret = texture2DLod(projectionMap, tc, lod);
-	ret.rgb = srgb_to_linear(ret.rgb);
 	
 	vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
 	
@@ -103,7 +95,6 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
 vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
 {
 	vec4 ret = texture2DLod(projectionMap, tc, lod);
-	ret = correctWithGamma(ret);
 	
 	vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
 	
@@ -121,7 +112,6 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
 vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
 {
 	vec4 ret = texture2DLod(projectionMap, tc, lod);
-	ret = correctWithGamma(ret);
 	
 	vec2 dist = tc-vec2(0.5);
 	
diff --git a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl
index 9c050256dc1c7301efecbfae3184dab7279f9f65..90ab5d27935bfd504f18fb231035ce42d39d9616 100644
--- a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl
+++ b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl
@@ -61,14 +61,17 @@ vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten)
 	return mix(atmosTransportFrag(light.rgb, additive, atten), (light.rgb + additive.rgb) * (2.0 - brightness), brightness * brightness);
 }
 
-vec3 atmosTransport(vec3 light) {
-     return (no_atmo == 1) ? light : atmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation());
+vec3 atmosTransport(vec3 light)
+{
+     return atmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation());
 }
 
-vec3 fullbrightAtmosTransport(vec3 light) {
-     return (no_atmo == 1) ? light : fullbrightAtmosTransportFrag(light, GetAdditiveColor(), getAtmosAttenuation());
+vec3 fullbrightAtmosTransport(vec3 light)
+{
+     return fullbrightAtmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation());
 }
 
-vec3 fullbrightShinyAtmosTransport(vec3 light) {
-    return (no_atmo == 1) ? light : fullbrightShinyAtmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation());
+vec3 fullbrightShinyAtmosTransport(vec3 light)
+{
+    return fullbrightShinyAtmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation());
 }