diff --git a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl
index 0ffca8515c30cad38239e2849c8cf930827c3fd8..f0522850de8c234e2b17b64a1051720b9fcc054b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl
@@ -44,7 +44,6 @@ void main()
 	float shadow = 1.0;
 
 	vec4 color = diffuseLookup(vary_texcoord0.xy)*vertex_color;
-	color.rgb = pow(color.rgb, vec3(2.2));
 	color.rgb = fullbrightAtmosTransport(color.rgb);
 
 	color.rgb = fullbrightScaleSoftClip(color.rgb);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
index c104dc884f15830369fe09197eead2aa71b760db..46ec20c8b09f202b8d31716cc23f974b6788ff29 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
@@ -79,11 +79,9 @@ void main()
 	color.rgb = fogged.rgb;
 	color.a   = fogged.a;
 #else
-    color.rgb = srgb_to_linear(color.rgb);
-	color.rgb = fullbrightAtmosTransport(color.rgb);
+    color.rgb = fullbrightAtmosTransport(color.rgb);
 	color.rgb = fullbrightScaleSoftClip(color.rgb);
-    color.rgb = linear_to_srgb(color.rgb);
-	color.a   = final_alpha;
+    color.a   = final_alpha;
 #endif
 
 	frag_color.rgb = color.rgb;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index 5999063ae53007f519f81dea89eb1a5f5b08578d..a8a5cc22dba2737862576d1713f1e2eaa163337e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -44,6 +44,9 @@ vec4 applyWaterFogView(vec3 pos, vec4 color);
 vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten);
 vec3 scaleSoftClipFrag(vec3 l);
 
+vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten);
+vec3 fullbrightScaleSoftClip(vec3 light);
+
 void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao);
 
 vec3 srgb_to_linear(vec3 cs);
@@ -215,6 +218,15 @@ void main()
 
     vec4 diffuse_srgb = texture2D(diffuseMap, vary_texcoord0.xy);
     diffuse_srgb.rgb *= vertex_color.rgb;
+    
+    // For some reason the Transparency slider sets vertex_color.a to 0.0 both for
+    // fully opaque and for fully transparent objects. This code assumes the 0 alpha
+    // is always from the opaque end of the scale. TODO: Remove the conditional once
+    // the root cause of the slider ambiguity is fixed.
+    if (vertex_color.a > 0.0)
+    {
+        diffuse_srgb.a *= vertex_color.a;
+    }
     vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a);
 
 #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK)
@@ -320,21 +332,26 @@ void main()
     vec3 atten;
 
     calcAtmosphericVars(pos.xyz, light_dir, 1.0, sunlit, amblit, additive, atten, false);
-
+    
     if (emissive_brightness >= 1.0)	// fullbright, skip lighting calculations
     {
-        // just do atmos attenuation (ad hoc 60% factor to match release viewer)
-        color = atmosFragLighting(diffuse_srgb.rgb, additive, atten*0.6);
-        color = scaleSoftClipFrag(color);
+        color = fullbrightAtmosTransportFrag(diffuse_srgb.rgb, additive, atten);
+        color = fullbrightScaleSoftClip(color);
+
         al = diffuse_srgb.a;
     }
     else // not fullbright, calculate lighting
     {
         vec3 refnormpersp = normalize(reflect(pos.xyz, norm));
 
+        //we're in sRGB space, so gamma correct this dot product so 
+        // lighting from the sun stays sharp
         float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0);
         da = pow(da, 1.0 / 1.3);
 
+        //darken ambient for normals perpendicular to light vector so surfaces in shadow 
+        // and facing away from light still have some definition to them.
+        // do NOT gamma correct this dot product so ambient lighting stays soft
         float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0);
         ambient *= 0.5;
         ambient *= ambient;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 547a159f3a37e9ecf88f439032db0515afc3588b..20ac78947be317a66c57158b465218b9c3467880 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -154,8 +154,6 @@ vec3 post_diffuse = color.rgb;
         }
        
  vec3 post_spec = color.rgb;
- 
-        color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a);
 
         if (envIntensity > 0.0)
         { //add environmentmap
@@ -165,7 +163,11 @@ vec3 post_diffuse = color.rgb;
             color = mix(color.rgb, reflected_color, envIntensity*0.75); // MAGIC NUMBER SL-12574; ALM: On, Quality <= Mid+
 #endif
         }
-        
+        else
+        {
+            color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a);
+        }
+
 vec3 post_env = color.rgb;
 
         if (norm.w < 1)
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index 2216afe609028d821809f80ce5641e8b55e6871d..694b19cdfb7ca64471ca9d717f758dbdde3071e4 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -177,9 +177,8 @@ void main()
 	float da = dot(norm, lv);
 		
 	vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
-    // SL-12005 Projector light pops as we get closer, more objectionable than being in wrong color space.
-    //          We can't switch to linear here unless we do it everywhere
-    //diff_tex.rgb = srgb_to_linear(diff_tex.rgb);
+	//light shaders output linear and are gamma corrected later in postDeferredGammaCorrectF.glsl
+    diff_tex.rgb = srgb_to_linear(diff_tex.rgb);
 
 	vec4 spec = texture2DRect(specularRect, frag.xy);
 
@@ -274,6 +273,7 @@ void main()
 	}
 #endif
 
+	//col.r = 1.0;
 	frag_color.rgb = col;	
 	frag_color.a = 0.0;
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 15a3bc349a0287fac8634146981e4cc789b687ce..9c7a4df76746b0cd1f76f030781a7de0d6e34550 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -161,8 +161,6 @@ vec3 post_diffuse = color.rgb;
         }
        
  vec3 post_spec = color.rgb;
- 
-        color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a);
 
         if (envIntensity > 0.0)
         { //add environmentmap
@@ -172,7 +170,11 @@ vec3 post_diffuse = color.rgb;
             color = mix(color.rgb, reflected_color, envIntensity*0.75); // MAGIC NUMBER SL-12574; ALM: On, Quality >= High
 #endif
         }
-        
+        else
+        {
+            color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a);
+        }
+
 vec3 post_env = color.rgb;
 
         if (norm.w < 1)
diff --git a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl
index 8fc5d750e36be379fb6f09bf6e54b6ee9f7fc8a1..f69d36f715897830e1ac6a0695f8e960592a08b8 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl
@@ -49,10 +49,15 @@ vec3 atmosTransport(vec3 light)
      return atmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation());
 }
 
-vec3 fullbrightAtmosTransport(vec3 light)
+vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten)
 {
     float brightness = dot(light.rgb * 0.5, vec3(0.3333)) + 0.1;
-    return atmosTransportFrag(light * 0.5, getAdditiveColor() * brightness, getAtmosAttenuation());
+    return atmosTransportFrag(light * 0.5, additive * brightness, atten);
+}
+
+vec3 fullbrightAtmosTransport(vec3 light)
+{
+    return fullbrightAtmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation());
 }
 
 vec3 fullbrightShinyAtmosTransport(vec3 light)
diff --git a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl
index 18705f785f60a9a387adc43bc36705b95176bd9c..aa7dbc39ce23a717015bd1821c8dc3a41bdd466e 100644
--- a/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl
+++ b/indra/newview/app_settings/shaders/class3/windlight/transportF.glsl
@@ -49,10 +49,15 @@ vec3 atmosTransport(vec3 light)
      return atmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation());
 }
 
-vec3 fullbrightAtmosTransport(vec3 light)
+vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten)
 {
     float brightness = dot(light.rgb, vec3(0.33333));
-    return atmosTransportFrag(light * 0.5, getAdditiveColor() * (brightness * 0.5 + 0.5), getAtmosAttenuation());
+    return atmosTransportFrag(light * 0.5, additive * (brightness * 0.5 + 0.5), atten);
+}
+
+vec3 fullbrightAtmosTransport(vec3 light)
+{
+    return atmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation());
 }
 
 vec3 fullbrightShinyAtmosTransport(vec3 light)
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index f32f34c354c7e59d41d74785358c29ef0b349264..8a894c4ec813501b0bad24f93773e219b30941f0 100644
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -108,6 +108,10 @@ const double RETAIN_COEFFICIENT = 100;
 // So this const is used as a size of Smooth combobox list.
 const S32 SMOOTH_VALUES_NUMBER = 10;
 
+// mCameraDistance
+// Also see: mCameraZoom
+const F32 MODEL_PREVIEW_CAMERA_DISTANCE = 16.f;
+
 void drawBoxOutline(const LLVector3& pos, const LLVector3& size);
 
 
@@ -431,7 +435,7 @@ void LLFloaterModelPreview::initModelPreview()
 	}
 
 	mModelPreview = new LLModelPreview(512, 512, this );
-	mModelPreview->setPreviewTarget(16.f);
+	mModelPreview->setPreviewTarget(MODEL_PREVIEW_CAMERA_DISTANCE);
 	mModelPreview->setDetailsCallback(boost::bind(&LLFloaterModelPreview::setDetails, this, _1, _2, _3, _4, _5));
 	mModelPreview->setModelUpdatedCallback(boost::bind(&LLFloaterModelPreview::modelUpdated, this, _1));
 }
@@ -3641,10 +3645,9 @@ BOOL LLModelPreview::render()
 	S32 width = getWidth();
 	S32 height = getHeight();
 
-	LLGLSUIDefault def;
+	LLGLSUIDefault def; // GL_BLEND, GL_ALPHA_TEST, GL_CULL_FACE, depth test
 	LLGLDisable no_blend(GL_BLEND);
-	LLGLEnable cull(GL_CULL_FACE);
-	LLGLDepthTest depth(GL_TRUE);
+	LLGLDepthTest depth(GL_FALSE); // SL-12781 disable z-buffer to render background color
 	LLGLDisable fog(GL_FOG);
 
 	{
@@ -3652,7 +3655,7 @@ BOOL LLModelPreview::render()
 		{
 			gUIProgram.bind();
 		}
-		//clear background to blue
+		//clear background to grey
 		gGL.matrixMode(LLRender::MM_PROJECTION);
 		gGL.pushMatrix();
 		gGL.loadIdentity();
@@ -3757,7 +3760,7 @@ BOOL LLModelPreview::render()
 
 	F32 explode = mFMP->childGetValue("physics_explode").asReal();
 
-	glClear(GL_DEPTH_BUFFER_BIT);
+	LLGLDepthTest gls_depth(GL_TRUE); // SL-12781 re-enable z-buffer for 3D model preview
 
 	LLRect preview_rect;
 
@@ -3780,7 +3783,6 @@ BOOL LLModelPreview::render()
 		target_pos = getPreviewAvatar()->getPositionAgent();
 		z_near = 0.01f;
 		z_far = 1024.f;
-		mCameraDistance = 16.f;
 
 		//render avatar previews every frame
 		refresh();
@@ -3920,9 +3922,9 @@ BOOL LLModelPreview::render()
 			{
 				glClear(GL_DEPTH_BUFFER_BIT);
 				
-				for (U32 i = 0; i < 2; i++)
+				for (U32 pass = 0; pass < 2; pass++)
 				{
-					if (i == 0)
+					if (pass == 0)
 					{ //depth only pass
 						gGL.setColorMask(false, false);
 					}
@@ -3932,7 +3934,7 @@ BOOL LLModelPreview::render()
 					}
 
 					//enable alpha blending on second pass but not first pass
-					LLGLState blend(GL_BLEND, i); 
+					LLGLState blend(GL_BLEND, pass);
 					
 					gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA);
 
diff --git a/indra/newview/llweb.cpp b/indra/newview/llweb.cpp
index 840eb06acfcc77ed5a1c3232edf2acbd6c86f4bf..a34c5826edcd55c34aa00bcb3929011bad563753 100644
--- a/indra/newview/llweb.cpp
+++ b/indra/newview/llweb.cpp
@@ -247,6 +247,5 @@ bool LLWeb::useExternalBrowser(const std::string &url)
 		boost::match_results<std::string::const_iterator> matches;
 		return boost::regex_search(url, matches, pattern);
 	}
-	return false;
 #endif
 }
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index eff509cd6c4994ab51d8adadaecdde8f1b27d510..52226a06fc1a4bb5e737706a2ace34848c2c9e48 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1286,7 +1286,7 @@ void LLPipeline::createGLBuffers()
 	}
 
     // Use FBO for bake tex
-    mBake.allocate(512, 512, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, true);
+    mBake.allocate(512, 512, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_TEXTURE, true); // SL-12781 Build > Upload > Model; 3D Preview
 
 	mHighlight.allocate(256,256,GL_RGBA, FALSE, FALSE);