From 393d9c7a620a4db05d0016934a951ce84be5f6cf Mon Sep 17 00:00:00 2001
From: Drake Arconis <drake@alchemyviewer.org>
Date: Fri, 14 Apr 2017 14:24:55 -0400
Subject: [PATCH] Remove rect texture extension usage and switch to
 GL_TEXTURE2D with 0-1 coords

---
 indra/llrender/llgl.cpp                       |   5 -
 indra/llrender/llgl.h                         |   1 -
 indra/llrender/llrender.cpp                   |   5 -
 indra/llrender/llrender.h                     |   1 -
 indra/llrender/llrendertarget.cpp             |  15 +-
 indra/llrender/llshadermgr.cpp                |   8 +-
 indra/llrender/llshadermgr.h                  |   5 +-
 indra/newview/app_settings/logcontrol.xml     |   1 -
 .../shaders/class1/avatar/eyeballF.glsl       |  34 ---
 .../shaders/class1/avatar/eyeballV.glsl       |  59 -----
 .../shaders/class1/deferred/SSAOF.glsl        |  24 +-
 .../shaders/class1/deferred/alphaF.glsl       |   1 -
 .../shaders/class1/deferred/blurLightF.glsl   |  60 +++--
 .../shaders/class1/deferred/blurLightV.glsl   |  39 ---
 .../shaders/class1/deferred/cofF.glsl         |  11 +-
 .../shaders/class1/deferred/diffuseV.glsl     |   2 +-
 .../shaders/class1/deferred/dofCombineF.glsl  |  28 +--
 .../deferred/downsampleDepthNearestF.glsl     |   6 +-
 .../class1/deferred/fullbrightShinyF.glsl     |   2 -
 .../shaders/class1/deferred/fxaaF.glsl        |   3 +-
 .../shaders/class1/deferred/luminanceF.glsl   |  39 ---
 .../shaders/class1/deferred/luminanceV.glsl   |  45 ----
 .../shaders/class1/deferred/materialF.glsl    |   2 -
 .../shaders/class1/deferred/materialV.glsl    |   1 -
 .../class1/deferred/multiPointLightF.glsl     |  23 +-
 .../class1/deferred/multiSpotLightF.glsl      |  30 +--
 .../shaders/class1/deferred/pointLightF.glsl  |  25 +-
 .../class1/deferred/postDeferredF.glsl        |  11 +-
 .../deferred/postDeferredGammaCorrectF.glsl   |   5 +-
 .../class1/deferred/postDeferredNoDoFF.glsl   |   7 +-
 .../class1/deferred/postDeferredNoTCV.glsl    |   4 +-
 .../class1/deferred/postDeferredV.glsl        |  44 ----
 .../shaders/class1/deferred/postgiF.glsl      | 102 --------
 .../shaders/class1/deferred/softenLightF.glsl |  27 +-
 .../shaders/class1/deferred/softenLightV.glsl |  40 ---
 .../shaders/class1/deferred/spotLightF.glsl   |  45 +---
 .../class1/deferred/sunLightNoFragCoordV.glsl |   2 -
 .../class1/deferred/sunLightSSAOF.glsl        |  11 +-
 .../shaders/class1/deferred/sunLightV.glsl    |  41 ----
 .../shaders/class1/deferred/waterF.glsl       |  24 --
 .../shaders/class1/effects/glowExtractF.glsl  |   4 +-
 .../shaders/class1/effects/glowExtractV.glsl  |   7 +-
 .../shaders/class1/effects/glowV.glsl         |  21 +-
 .../interface/downsampleDepthRectF.glsl       |  67 -----
 .../class1/interface/downsampleDepthV.glsl    |   4 +-
 .../class1/interface/glowcombineF.glsl        |   7 +-
 .../class1/interface/glowcombineFXAAF.glsl    |   7 +-
 .../class1/interface/glowcombineFXAAV.glsl    |   4 +-
 .../class1/interface/glowcombineV.glsl        |   9 +-
 .../class1/interface/splattexturerectF.glsl   |   4 +-
 .../shaders/class2/avatar/eyeballV.glsl       |  62 -----
 .../class2/deferred/multiSpotLightF.glsl      |  92 +++----
 .../shaders/class2/deferred/softenLightF.glsl |  26 +-
 .../shaders/class2/deferred/softenLightV.glsl |  42 ----
 .../shaders/class2/deferred/spotLightF.glsl   |  28 +--
 .../shaders/class2/deferred/sunLightF.glsl    |  12 +-
 .../class2/deferred/sunLightSSAOF.glsl        |  17 +-
 .../shaders/class2/deferred/sunLightV.glsl    |  41 ----
 .../class2/lighting/sumLightsSpecularV.glsl   |   2 +-
 .../class2/windlight/atmosphericsV.glsl       |   2 +-
 .../app_settings/shaders/shader_hierarchy.txt |  19 --
 indra/newview/lldrawpoolwater.cpp             |   2 +-
 indra/newview/llviewershadermgr.cpp           |  48 +---
 indra/newview/llviewershadermgr.h             |   4 +-
 indra/newview/pipeline.cpp                    | 231 ++++++------------
 indra/newview/pipeline.h                      |   4 +-
 66 files changed, 329 insertions(+), 1275 deletions(-)
 delete mode 100644 indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl
 delete mode 100644 indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl
 delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl
 delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
 delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl
 delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl
 delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
 delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
 delete mode 100644 indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl
 delete mode 100644 indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl
 delete mode 100644 indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl
 delete mode 100644 indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
 delete mode 100644 indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl

diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 94e3f13d7b..404a6f4f19 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -184,7 +184,6 @@ LLGLManager::LLGLManager() :
 	mHasPointParameters(FALSE),
 	mHasDrawBuffers(FALSE),
 	mHasDepthClamp(FALSE),
-	mHasTextureRectangle(FALSE),
 	mHasTransformFeedback(FALSE),
 	mMaxSampleMaskWords(0),
 	mMaxColorTextureSamples(0),
@@ -680,7 +679,6 @@ void LLGLManager::initExtensions()
 	mHasOcclusionQuery = FALSE;
 	mHasPointParameters = FALSE;
 	mHasShaderObjects = FALSE;
-	mHasTextureRectangle = FALSE;
 #elif LL_DARWIN
     std::set<std::string> extensions;
     const auto extensionString = glGetString(GL_EXTENSIONS);
@@ -739,7 +737,6 @@ void LLGLManager::initExtensions()
     
     mHasDrawBuffers = extensions.find("GL_ARB_draw_buffers") != extensions.end();
     mHasBlendFuncSeparate = extensions.find("GL_EXT_blend_func_separate") != extensions.end();
-    mHasTextureRectangle = extensions.find("GL_ARB_texture_rectangle") != extensions.end();
     mHasDebugOutput = extensions.find("GL_ARB_debug_output") != extensions.end();
     mHasTransformFeedback = mGLVersion >= 4.f || extensions.find("GL_EXT_transform_feedback") != extensions.end();
 #if !LL_DARWIN
@@ -801,7 +798,6 @@ void LLGLManager::initExtensions()
 
 	mHasDrawBuffers = GLEW_ARB_draw_buffers;
 	mHasBlendFuncSeparate = GLEW_EXT_blend_func_separate;
-	mHasTextureRectangle = GLEW_ARB_texture_rectangle;
 	mHasDebugOutput = GLEW_ARB_debug_output;
 	mHasTransformFeedback = mGLVersion >= 4.f || GLEW_EXT_transform_feedback;
 #if !LL_DARWIN
@@ -883,7 +879,6 @@ void LLGLManager::initExtensions()
 		if (strchr(blacklist,'p')) mHasPointParameters = FALSE;//S
 		if (strchr(blacklist,'q')) mHasFramebufferObject = FALSE;//S
 		if (strchr(blacklist,'r')) mHasDrawBuffers = FALSE;//S
-		if (strchr(blacklist,'s')) mHasTextureRectangle = FALSE;
 		if (strchr(blacklist,'t')) mHasBlendFuncSeparate = FALSE;//S
 		if (strchr(blacklist,'u')) mHasDepthClamp = FALSE;
 		
diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h
index 8f6c37b0e3..af17cde1f6 100644
--- a/indra/llrender/llgl.h
+++ b/indra/llrender/llgl.h
@@ -104,7 +104,6 @@ public:
 	BOOL mHasPointParameters;
 	BOOL mHasDrawBuffers;
 	BOOL mHasDepthClamp;
-	BOOL mHasTextureRectangle;
 	BOOL mHasTransformFeedback;
 	S32 mMaxSampleMaskWords;
 	S32 mMaxColorTextureSamples;
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 5ea6785a01..46c47882bf 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -65,7 +65,6 @@ static const U32 LL_NUM_LIGHT_UNITS = 8;
 static const GLenum sGLTextureType[] =
 {
 	GL_TEXTURE_2D,
-	GL_TEXTURE_RECTANGLE_ARB,
 	GL_TEXTURE_CUBE_MAP_ARB
 };
 
@@ -1917,7 +1916,6 @@ void LLRender::flush()
 		
 		//store mCount in a local variable to avoid re-entrance (drawArrays may call flush)
 		U32 count = mCount;
-
 		if (mMode == LLRender::TRIANGLES)
 		{
 			if (mCount%3 != 0)
@@ -2327,9 +2325,6 @@ void LLRender::debugTexUnits(void)
 				case LLTexUnit::TT_TEXTURE:
 					LL_CONT << "Texture 2D";
 					break;
-				case LLTexUnit::TT_RECT_TEXTURE:
-					LL_CONT << "Texture Rectangle";
-					break;
 				case LLTexUnit::TT_CUBE_MAP:
 					LL_CONT << "Cube Map";
 					break;
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index 17a637ac77..51e8fe70e0 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -63,7 +63,6 @@ public:
 	typedef enum
 	{
 		TT_TEXTURE = 0,			// Standard 2D Texture
-		TT_RECT_TEXTURE,	// Non power of 2 texture
 		TT_CUBE_MAP,		// 6-sided cube map texture
 		TT_NONE 		// No texture type is currently enabled
 	} eTextureType;
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index eb3c8b4800..fc78b38008 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -220,18 +220,9 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)
 		stop_glerror();
 	}
 
-	if (mUsage != LLTexUnit::TT_RECT_TEXTURE)
-	{
-		gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_MIRROR);
-		stop_glerror();
-	}
-	else
-	{
-		// ATI doesn't support mirrored repeat for rectangular textures.
-		gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
-		stop_glerror();
-	}
-		
+	gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_MIRROR);
+	stop_glerror();
+
 	if (mFBO)
 	{
 		stop_glerror();
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index 35872f9742..4e9e81950e 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -1234,8 +1234,6 @@ void LLShaderMgr::initAttribsAndUniforms()
 	mReservedUniforms.push_back("object_plane_t");
 	llassert(mReservedUniforms.size() == LLShaderMgr::OBJECT_PLANE_T+1);
 
-	mReservedUniforms.push_back("viewport");
-
 	mReservedUniforms.push_back("light_position");
 	mReservedUniforms.push_back("light_direction");
 	mReservedUniforms.push_back("light_attenuation");
@@ -1326,7 +1324,8 @@ void LLShaderMgr::initAttribsAndUniforms()
 	mReservedUniforms.push_back("ssao_factor");
 	mReservedUniforms.push_back("ssao_factor_inv");
 	mReservedUniforms.push_back("ssao_effect");
-	mReservedUniforms.push_back("screen_res");
+	mReservedUniforms.push_back("kern_scale");
+	mReservedUniforms.push_back("noise_scale");
 	mReservedUniforms.push_back("near_clip");
 	mReservedUniforms.push_back("shadow_offset");
 	mReservedUniforms.push_back("shadow_bias");
@@ -1340,9 +1339,8 @@ void LLShaderMgr::initAttribsAndUniforms()
 	mReservedUniforms.push_back("shadow_target_width");
 	mReservedUniforms.push_back("downsampled_depth_scale");
 	
-	llassert(mReservedUniforms.size() == LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH+1);
+	llassert(mReservedUniforms.size() == LLShaderMgr::DEFERRED_DOWNSAMPLED_DEPTH_SCALE+1);
 
-	mReservedUniforms.push_back("tc_scale");
 	mReservedUniforms.push_back("rcp_screen_res");
 	mReservedUniforms.push_back("rcp_frame_opt");
 	mReservedUniforms.push_back("rcp_frame_opt2");
diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h
index 60ac6102bb..6ef114dc66 100644
--- a/indra/llrender/llshadermgr.h
+++ b/indra/llrender/llshadermgr.h
@@ -49,7 +49,6 @@ public:
 		TEXTURE_MATRIX3,
 		OBJECT_PLANE_S,
 		OBJECT_PLANE_T,
-		VIEWPORT,
 		LIGHT_POSITION,
 		LIGHT_DIRECTION,
 		LIGHT_ATTENUATION,
@@ -124,7 +123,8 @@ public:
 		DEFERRED_SSAO_FACTOR,
 		DEFERRED_SSAO_FACTOR_INV,
 		DEFERRED_SSAO_EFFECT,
-		DEFERRED_SCREEN_RES,
+		DEFERRED_KERN_SCALE,
+		DEFERRED_NOISE_SCALE,
 		DEFERRED_NEAR_CLIP,
 		DEFERRED_SHADOW_OFFSET,
 		DEFERRED_SHADOW_BIAS,
@@ -138,7 +138,6 @@ public:
 		DEFERRED_SHADOW_TARGET_WIDTH,
 		DEFERRED_DOWNSAMPLED_DEPTH_SCALE,
 
-		FXAA_TC_SCALE,
 		FXAA_RCP_SCREEN_RES,
 		FXAA_RCP_FRAME_OPT,
 		FXAA_RCP_FRAME_OPT2,
diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml
index ecd7c4bc36..f5f0c37fbb 100644
--- a/indra/newview/app_settings/logcontrol.xml
+++ b/indra/newview/app_settings/logcontrol.xml
@@ -19,7 +19,6 @@
 						</array>
 					<key>tags</key>
 						<array>
-							<string>ShaderLoading</string>
 						</array>
 				</map>
 				<map>
diff --git a/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl b/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl
deleted file mode 100644
index 4296e551db..0000000000
--- a/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl
+++ /dev/null
@@ -1,34 +0,0 @@
-/** 
- * @file eyeballF.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$
- */
- 
-
-
-void default_lighting();
-
-void main() 
-{
-	default_lighting();
-}
-	
diff --git a/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl b/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl
deleted file mode 100644
index 82db15c3ae..0000000000
--- a/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl
+++ /dev/null
@@ -1,59 +0,0 @@
-/** 
- * @file eyeballV.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$
- */
-
-uniform mat3 normal_matrix;
-uniform mat4 texture_matrix0;
-uniform mat4 modelview_matrix;
-uniform mat4 modelview_projection_matrix;
-
-ATTRIBUTE vec3 position;
-ATTRIBUTE vec4 diffuse_color;
-ATTRIBUTE vec3 normal;
-ATTRIBUTE vec2 texcoord0;
-
-VARYING vec4 vertex_color;
-VARYING vec2 vary_texcoord0;
-
-vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol);
-void calcAtmospherics(vec3 inPositionEye);
-
-void main()
-{
-	//transform vertex
-	vec3 pos = (modelview_matrix * vec4(position.xyz, 1.0)).xyz;
-	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
-	vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
-	
-	
-	vec3 norm = normalize(normal_matrix * normal);
-		
-	calcAtmospherics(pos.xyz);
-
-	vec4 specular = vec4(1.0);
-	vec4 color = calcLightingSpecular(pos, norm, diffuse_color, specular, vec4(0.0));	
-	vertex_color = color;
-
-}
-
diff --git a/indra/newview/app_settings/shaders/class1/deferred/SSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/SSAOF.glsl
index 79129d302d..518b198597 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/SSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/SSAOF.glsl
@@ -23,8 +23,6 @@
  * $/LicenseInfo$
  */
  
-//#extension GL_ARB_texture_rectangle : enable
-
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
@@ -33,18 +31,17 @@ out vec4 frag_color;
 
 VARYING vec2 vary_fragcoord;
 
-uniform sampler2DRect depthMapDownsampled;
-uniform sampler2DRect normalMap;
+uniform sampler2D depthMapDownsampled;
+uniform sampler2D normalMap;
 uniform sampler2D noiseMap;
 
-uniform vec2 screen_res;
 uniform mat4 inv_proj;
 
-uniform float downsampled_depth_scale;
-
 uniform float ssao_radius;
 uniform float ssao_max_radius;
 uniform float ssao_factor;
+uniform vec2 kern_scale;
+uniform vec2 noise_scale;
 
 vec3 decode_normal (vec2 enc)
 {
@@ -59,9 +56,8 @@ vec3 decode_normal (vec2 enc)
 
 vec4 getPosition(vec2 pos_screen)
 {
-	float depth = texture2DRect(depthMapDownsampled, pos_screen.xy*downsampled_depth_scale).r;
+	float depth = texture2D(depthMapDownsampled, pos_screen.xy).r;
 	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
 	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
 	vec4 pos = inv_proj * ndc;
@@ -90,7 +86,7 @@ vec2 getKern(int i)
 float calcAmbientOcclusion(vec4 pos, vec3 norm)
 {
   vec2 pos_screen = vary_fragcoord.xy;
-  vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
+  vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy * noise_scale).xy;
 
   // We treat the first sample as the origin, which definitely doesn't obscure itself thanks to being visible for sampling in the first place.
   float points = 1.0;
@@ -98,7 +94,7 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm)
 		
   // use a kernel scale that diminishes with distance.
   // a scale of less than 32 is just wasting good samples, though.
-  float scale = max(32.0, min(ssao_radius / -pos.z, ssao_max_radius));
+  vec2 scale = max(32.0, min(ssao_radius / -pos.z, ssao_max_radius)) * kern_scale;
 
   // it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
   for (int i = 0; i < 8; i++)
@@ -106,8 +102,8 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm)
     vec2 samppos_screen = pos_screen + scale * reflect(getKern(i), noise_reflect);
 
     // if sample is out-of-screen then give it no weight by continuing
-    if (any(lessThan(samppos_screen.xy, vec2(0.0, 0.0))) ||
-	any(greaterThan(samppos_screen.xy, vec2(screen_res.xy)))) continue;
+    //if (any(lessThan(samppos_screen.xy, vec2(0.0, 0.0))) ||
+    //  any(greaterThan(samppos_screen.xy, vec2(screen_res.xy)))) continue;
 
     vec3 samppos_world = getPosition(samppos_screen).xyz; 
 			
@@ -144,7 +140,7 @@ void main()
 	
 	vec4 pos = getPosition(pos_screen);
 	
-	vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
+	vec3 norm = texture2D(normalMap, pos_screen).xyz;
 	norm = decode_normal(norm.xy);
 
 	frag_color = vec4(calcAmbientOcclusion(pos,norm),0,0,0);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 91fc26076a..9f8865a5c2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -87,7 +87,6 @@ vec3 vary_AdditiveColor;
 vec3 vary_AtmosAttenuation;
 
 uniform mat4 inv_proj;
-uniform vec2 screen_res;
 
 uniform vec4 light_position[8];
 uniform vec3 light_direction[8];
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index 8f508b48d3..a5631144f8 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -31,26 +31,34 @@ out vec4 frag_color;
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
-uniform sampler2DRect lightMap;
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
+uniform sampler2D lightMap;
 
 uniform float dist_factor;
 uniform float blur_size;
 uniform vec2 delta;
-uniform vec3 kern[4];
-uniform float kern_scale;
+uniform vec2 kern_scale;
 
 VARYING vec2 vary_fragcoord;
 
 uniform mat4 inv_proj;
-uniform vec2 screen_res;
+
+vec2 getKern(int i)
+{
+	vec2 kern[4];
+	
+	kern[0] = vec2(0.3989422804,0.1994711402);
+	kern[1] = vec2(0.2419707245,0.1760326634);
+	kern[2] = vec2(0.0539909665,0.1209853623);
+	kern[3] = vec2(0.0044318484,0.0647587978);
+	return kern[i];
+}
 
 vec4 getPosition(vec2 pos_screen)
 {
-	float depth = texture2DRect(depthMap, pos_screen.xy).r;
+	float depth = texture2D(depthMap, pos_screen.xy).r;
 	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
 	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
 	vec4 pos = inv_proj * ndc;
@@ -78,17 +86,17 @@ vec3 decode_normal (vec2 enc)
 
 void main() 
 {
-    vec2 tc = vary_fragcoord.xy;
-	vec3 norm = texture2DRect(normalMap, tc).xyz;
+	vec2 tc = vary_fragcoord.xy;
+	vec3 norm = texture2D(normalMap, tc).xyz;
 	norm = decode_normal(norm.xy); // unpack norm
 
 	vec3 pos = getPosition(tc).xyz;
-	vec4 ccol = texture2DRect(lightMap, tc).rgba;
-	
-	vec2 dlt = kern_scale * delta / (vec2(1.0)+norm.xy*norm.xy);
+	vec4 ccol = texture2D(lightMap, tc).rgba;
+
+	vec2 dlt = delta / (vec2(1.0)+norm.xy*norm.xy);
 	dlt /= max(-pos.z*dist_factor, 1.0);
 	
-	vec2 defined_weight = kern[0].xy; // special case the first (centre) sample's weight in the blur; we have to sample it anyway so we get it for 'free'
+	vec2 defined_weight = getKern(0).xy; // special case the first (centre) sample's weight in the blur; we have to sample it anyway so we get it for 'free'
 	vec4 col = defined_weight.xyxx * ccol;
 
 	// relax tolerance according to distance to avoid speckling artifacts, as angles and distances are a lot more abrupt within a small screen area at larger distances
@@ -96,34 +104,34 @@ void main()
 
 	for (int i = 3; i > 0; i--)
 	{
-		vec2 samptc = tc + kern[i].z*dlt;
-	    vec3 samppos = getPosition(samptc).xyz; 
-
+		vec2 samptc = (tc + i * dlt);
+		vec3 samppos = getPosition(samptc).xyz; 
 		float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane
-		
+
 		if (d*d <= pointplanedist_tolerance_pow2)
 		{
-			col += texture2DRect(lightMap, samptc)*kern[i].xyxx;
-			defined_weight += kern[i].xy;
+			vec4 weight = getKern(i).xyxx;
+			col += texture2D(lightMap, samptc)*weight;
+			defined_weight += weight.xy;
 		}
 	}
 
 	for (int i = 1; i < 4; i++)
 	{
-		vec2 samptc = tc - kern[i].z*dlt;
+		vec2 samptc = (tc - i * dlt);
 	    vec3 samppos = getPosition(samptc).xyz; 
-
 		float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane
-		
+
 		if (d*d <= pointplanedist_tolerance_pow2)
 		{
-			col += texture2DRect(lightMap, samptc)*kern[i].xyxx;
-			defined_weight += kern[i].xy;
+			vec4 weight = getKern(i).xyxx;
+			col += texture2D(lightMap, samptc)*weight;
+			defined_weight += weight.xy;
 		}
 	}
 
 	col /= defined_weight.xyxx;
-	//col.y *= col.y; // delinearize SSAO effect post-blur
+	//col.y *= col.y; // delinearize SSAO effect post-blur    // Singu note: Performed pre-blur as to remove blur requirement
 	
 	frag_color = col;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl
deleted file mode 100644
index 212f7e56ad..0000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl
+++ /dev/null
@@ -1,39 +0,0 @@
-/** 
- * @file blurLightF.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$
- */
-
-uniform mat4 modelview_projection_matrix;
-
-ATTRIBUTE vec3 position;
-
-VARYING vec2 vary_fragcoord;
-uniform vec2 screen_res;
-
-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/class1/deferred/cofF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl
index ad38c51e54..16117acb3d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/cofF.glsl
@@ -31,8 +31,8 @@ out vec4 frag_color;
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect depthMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D depthMap;
 uniform sampler2D bloomMap;
 
 uniform float depth_cutoff;
@@ -44,13 +44,12 @@ uniform float magnification;
 uniform float max_cof;
 
 uniform mat4 inv_proj;
-uniform vec2 screen_res;
 
 VARYING vec2 vary_fragcoord;
 
 float getDepth(vec2 pos_screen)
 {
-	float z = texture2DRect(depthMap, pos_screen.xy).r;
+	float z = texture2D(depthMap, pos_screen.xy).r;
 	z = z*2.0-1.0;
 	vec4 ndc = vec4(0.0, 0.0, z, 1.0);
 	vec4 p = inv_proj*ndc;
@@ -78,13 +77,13 @@ void main()
 	
 	float depth = getDepth(tc);
 	
-	vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
+	vec4 diff = texture2D(diffuseRect, vary_fragcoord.xy);
 	
 	float sc = calc_cof(depth);
 	sc = min(sc, max_cof);
 	sc = max(sc, -max_cof);
 	
-	vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy/screen_res);
+	vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy);
 	frag_color.rgb = diff.rgb + bloom.rgb;
 	frag_color.a = sc/max_cof*0.5+0.5;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
index 3c026796c8..76d29b1df7 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
@@ -47,6 +47,6 @@ void main()
 	
 	passTextureIndex();
 	vary_normal = normalize(normal_matrix * normal);
-	
+
 	vertex_color = diffuse_color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl b/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl
index 0ce614def6..a5a76c4a8f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/dofCombineF.glsl
@@ -31,26 +31,26 @@ out vec4 frag_color;
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect lightMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D lightMap;
 
 uniform mat4 inv_proj;
-uniform vec2 screen_res;
 
 uniform float max_cof;
 uniform float res_scale;
 uniform float dof_width;
 uniform float dof_height;
+uniform float kern_scale;
 uniform float seconds60;
 
 VARYING vec2 vary_fragcoord;
 
-vec4 dofSample(sampler2DRect tex, vec2 tc)
+vec4 dofSample(sampler2D tex, vec2 tc)
 {
 	tc.x = min(tc.x, dof_width);
 	tc.y = min(tc.y, dof_height);
 
-	return texture2DRect(tex, tc);
+	return texture2D(tex, tc);
 }
 
 float rand(vec2 co)
@@ -60,10 +60,11 @@ float rand(vec2 co)
 
 void main() 
 {
-	vec2 tc = vary_fragcoord.xy;
+	vec2 tc = vary_fragcoord.xy * res_scale;
 	
-	vec4 diff = texture2DRect(lightMap, tc.xy);
-	vec4 dof = dofSample(diffuseRect, tc.xy*res_scale);
+	vec4 diff = texture2D(lightMap, vary_fragcoord.xy);
+
+	vec4 dof = dofSample(diffuseRect, tc);
 	dof.a = 0.0;
 
 	float a = min(abs(diff.a*2.0-1.0) * max_cof*res_scale, 1.0);
@@ -73,12 +74,11 @@ void main()
 	{ //help out the transition a bit
 		float sc = a/res_scale;
 		
-		vec4 col;
-		col = diff;
-		col.rgb += texture2DRect(lightMap, tc.xy+vec2(sc,sc)).rgb;
-		col.rgb += texture2DRect(lightMap, tc.xy+vec2(-sc,sc)).rgb;
-		col.rgb += texture2DRect(lightMap, tc.xy+vec2(sc,-sc)).rgb;
-		col.rgb += texture2DRect(lightMap, tc.xy+vec2(-sc,-sc)).rgb;
+		vec4 col = diff;
+		col.rgb += texture2D(lightMap, vary_fragcoord.xy+vec2(sc,sc)*kern_scale).rgb;
+		col.rgb += texture2D(lightMap, vary_fragcoord.xy+vec2(-sc,sc)*kern_scale).rgb;
+		col.rgb += texture2D(lightMap, vary_fragcoord.xy+vec2(sc,-sc)*kern_scale).rgb;
+		col.rgb += texture2D(lightMap, vary_fragcoord.xy+vec2(-sc,-sc)*kern_scale).rgb;
 		
 		diff = mix(diff, col*0.2, a);
 	}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/downsampleDepthNearestF.glsl b/indra/newview/app_settings/shaders/class1/deferred/downsampleDepthNearestF.glsl
index 9b6355fb9f..1a5238226e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/downsampleDepthNearestF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/downsampleDepthNearestF.glsl
@@ -23,19 +23,17 @@
  * $/LicenseInfo$
  */
  
-//#extension GL_ARB_texture_rectangle : enable
-
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect depthMap;
+uniform sampler2D depthMap;
 
 VARYING vec2 vary_fragcoord;
 
 void main() 
 {
-	gl_FragDepth = texture2DRect(depthMap, vary_fragcoord.xy).r;
+	gl_FragDepth = texture2D(depthMap, vary_fragcoord.xy).r;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl
index b0db9876d3..3dd5fe0b74 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl
@@ -22,8 +22,6 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
-
 
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl
index 7412e53acd..3093ba2d5e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fxaaF.glsl
@@ -2106,11 +2106,10 @@ uniform vec2 rcp_screen_res;
 uniform vec4 rcp_frame_opt;
 uniform vec4 rcp_frame_opt2;
 VARYING vec2 vary_fragcoord;
-VARYING vec2 vary_tc;
 
 void main() 
 {
-	vec4 diff =			FxaaPixelShader(vary_tc,			//pos
+	vec4 diff =			FxaaPixelShader(vary_fragcoord,			//pos
 										vec4(vary_fragcoord.xy, 0, 0), //fxaaConsolePosPos
 										diffuseMap,					//tex
 										diffuseMap,					
diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
deleted file mode 100644
index dcf474824d..0000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
+++ /dev/null
@@ -1,39 +0,0 @@
-/** 
- * @file luminanceF.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$
- */
- 
-uniform sampler2DRect diffuseMap;
-
-#ifdef DEFINE_GL_FRAGCOLOR
-out vec4 frag_color;
-#else
-#define frag_color gl_FragColor
-#endif
-
-VARYING vec2 vary_fragcoord;
-
-void main() 
-{
-	frag_color = texture2DRect(diffuseMap, vary_fragcoord.xy);
-}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl
deleted file mode 100644
index f2dc60aa5d..0000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl
+++ /dev/null
@@ -1,45 +0,0 @@
-/** 
- * @file giV.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$
- */
-
-uniform mat4 modelview_projection_matrix;
- 
-ATTRIBUTE vec3 position;
-ATTRIBUTE vec4 diffuse_color;
-
-VARYING vec2 vary_fragcoord;
-VARYING vec4 vertex_color;
-
-uniform vec2 screen_res;
-
-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;	
-
-	vertex_color = diffuse_color;
-}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index 90f04859ad..1a4de17a93 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -143,7 +143,6 @@ vec3 vary_AdditiveColor;
 vec3 vary_AtmosAttenuation;
 
 uniform mat4 inv_proj;
-uniform vec2 screen_res;
 
 uniform vec4 light_position[8];
 uniform vec3 light_direction[8];
@@ -272,7 +271,6 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe
 vec4 getPosition_d(vec2 pos_screen, float depth)
 {
 	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
 	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
 	vec4 pos = inv_proj * ndc;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl
index b3e6449f1a..cb63da6ba8 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl
@@ -122,7 +122,6 @@ vary_normal  = n;
 #if HAS_NORMAL_MAP
 	vec3 t = normalize(normal_matrix * tangent.xyz);
 	vec3 b = cross(n,t)*tangent.w;
-	//vec3 t = cross(b,n) * binormal.w;
 	
 	vary_mat0 = vec3(t.x, b.x, n.x);
 	vary_mat1 = vec3(t.y, b.y, n.y);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index 2a3d6ee3a1..de8efe1b8f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -31,10 +31,10 @@ out vec4 frag_color;
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect depthMap;
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect normalMap;
+uniform sampler2D depthMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D normalMap;
 uniform samplerCube environmentMap;
 uniform sampler2D noiseMap;
 uniform sampler2D lightFunc;
@@ -49,11 +49,11 @@ uniform vec4 light[LIGHT_COUNT];
 uniform vec4 light_col[LIGHT_COUNT];
 
 VARYING vec4 vary_fragcoord;
-uniform vec2 screen_res;
 
 uniform float far_z;
 
 uniform mat4 inv_proj;
+uniform vec2 noise_scale;
 
 vec2 encode_normal(vec3 n)
 {
@@ -74,9 +74,8 @@ vec3 decode_normal (vec2 enc)
 
 vec4 getPosition(vec2 pos_screen)
 {
-	float depth = texture2DRect(depthMap, pos_screen.xy).r;
+	float depth = texture2D(depthMap, pos_screen.xy).r;
 	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
 	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
 	vec4 pos = inv_proj * ndc;
@@ -87,20 +86,20 @@ vec4 getPosition(vec2 pos_screen)
 
 void main() 
 {
-	vec2 frag = (vary_fragcoord.xy*0.5+0.5)*screen_res;
+	vec2 frag = (vary_fragcoord.xy*0.5+0.5);
 	vec3 pos = getPosition(frag.xy).xyz;
 	if (pos.z < far_z)
 	{
 		discard;
 	}
 	
-	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	vec3 norm = texture2D(normalMap, frag.xy).xyz;
 	norm = decode_normal(norm.xy); // unpack norm
 	norm = normalize(norm);
-	vec4 spec = texture2DRect(specularRect, frag.xy);
-	vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb;
+	vec4 spec = texture2D(specularRect, frag.xy);
+	vec3 diff = texture2D(diffuseRect, frag.xy).rgb;
 	
-	float noise = texture2D(noiseMap, frag.xy/128.0).b;
+	float noise = texture2D(noiseMap, frag.xy*noise_scale).b;
 	vec3 out_col = vec3(0,0,0);
 	vec3 npos = normalize(-pos);
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index fb82f0e081..c3d044301a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -32,12 +32,10 @@ out vec4 frag_color;
 //class 1 -- no shadows
 
 
-
-
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
 uniform samplerCube environmentMap;
 uniform sampler2D noiseMap;
 uniform sampler2D projectionMap;
@@ -64,9 +62,9 @@ uniform float falloff;
 uniform float size;
 
 VARYING vec4 vary_fragcoord;
-uniform vec2 screen_res;
 
 uniform mat4 inv_proj;
+uniform vec2 noise_scale;
 
 vec2 encode_normal(vec3 n)
 {
@@ -177,9 +175,8 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
 
 vec4 getPosition(vec2 pos_screen)
 {
-	float depth = texture2DRect(depthMap, pos_screen.xy).r;
+	float depth = texture2D(depthMap, pos_screen.xy).r;
 	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
 	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
 	vec4 pos = inv_proj * ndc;
@@ -193,7 +190,6 @@ void main()
 	vec4 frag = vary_fragcoord;
 	frag.xyz /= frag.w;
 	frag.xyz = frag.xyz*0.5+0.5;
-	frag.xy *= screen_res;
 	
 	vec3 pos = getPosition(frag.xy).xyz;
 	vec3 lv = center.xyz-pos.xyz;
@@ -204,7 +200,7 @@ void main()
 		discard;
 	}
 		
-	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	vec3 norm = texture2D(normalMap, frag.xy).xyz;
 	float envIntensity = norm.z;
 
 	norm = decode_normal(norm.xy);
@@ -236,10 +232,10 @@ void main()
 		
 	vec3 col = vec3(0,0,0);
 		
-	vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
+	vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
 	vec3 dlit = vec3(0, 0, 0);
 	
-	float noise = texture2D(noiseMap, frag.xy/128.0).b;
+	float noise = texture2D(noiseMap, frag.xy*noise_scale).b;
 	if (proj_tc.z > 0.0 &&
 		proj_tc.x < 1.0 &&
 		proj_tc.y < 1.0 &&
@@ -275,7 +271,7 @@ void main()
 	}
 	
 	
-	vec4 spec = texture2DRect(specularRect, frag.xy);
+	vec4 spec = texture2D(specularRect, frag.xy);
 	
 	if (spec.a > 0.0)
 	{
@@ -313,12 +309,12 @@ void main()
 		if (ds < 0.0)
 		{
 			vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds;
-			
+
 			vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0));
-            
+
 			if (stc.z > 0.0)
 			{
-                stc /= stc.w;
+				stc /= stc.w;
 								
 				if (stc.x < 1.0 &&
 					stc.y < 1.0 &&
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
index fc42c4bfe9..d9c30ab18c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
@@ -31,13 +31,13 @@ out vec4 frag_color;
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect normalMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D normalMap;
 uniform samplerCube environmentMap;
 uniform sampler2D noiseMap;
 uniform sampler2D lightFunc;
-uniform sampler2DRect depthMap;
+uniform sampler2D depthMap;
 
 uniform vec3 env_mat[3];
 uniform float sun_wash;
@@ -49,10 +49,9 @@ uniform float size;
 VARYING vec4 vary_fragcoord;
 VARYING vec3 trans_center;
 
-uniform vec2 screen_res;
-
 uniform mat4 inv_proj;
 uniform vec4 viewport;
+uniform vec2 noise_scale;
 
 vec2 encode_normal(vec3 n)
 {
@@ -73,9 +72,8 @@ vec3 decode_normal (vec2 enc)
 
 vec4 getPosition(vec2 pos_screen)
 {
-	float depth = texture2DRect(depthMap, pos_screen.xy).r;
-	vec2 sc = (pos_screen.xy-viewport.xy)*2.0;
-	sc /= viewport.zw;
+	float depth = texture2D(depthMap, pos_screen.xy).r;
+	vec2 sc = pos_screen.xy*2.0;
 	sc -= vec2(1.0,1.0);
 	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
 	vec4 pos = inv_proj * ndc;
@@ -89,7 +87,6 @@ void main()
 	vec4 frag = vary_fragcoord;
 	frag.xyz /= frag.w;
 	frag.xyz = frag.xyz*0.5+0.5;
-	frag.xy *= screen_res;
 	
 	vec3 pos = getPosition(frag.xy).xyz;
 	vec3 lv = trans_center.xyz-pos;
@@ -100,7 +97,7 @@ void main()
 		discard;
 	}
 	
-	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	vec3 norm = texture2D(normalMap, frag.xy).xyz;
 	norm = decode_normal(norm.xy); // unpack norm
 	float da = dot(norm, lv);
 	if (da < 0.0)
@@ -112,9 +109,9 @@ void main()
 	lv = normalize(lv);
 	da = dot(norm, lv);
 	
-	float noise = texture2D(noiseMap, frag.xy/128.0).b;
+	float noise = texture2D(noiseMap, frag.xy*noise_scale).b;
 	
-	vec3 col = texture2DRect(diffuseRect, frag.xy).rgb;
+	vec3 col = texture2D(diffuseRect, frag.xy).rgb;
 	float fa = falloff+1.0;
 	float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
 	dist_atten *= dist_atten;
@@ -124,7 +121,7 @@ void main()
 
 	col = color.rgb*lit*col;
 
-	vec4 spec = texture2DRect(specularRect, frag.xy);
+	vec4 spec = texture2D(specularRect, frag.xy);
 	if (spec.a > 0.0)
 	{
 		lit = min(da*6.0, 1.0) * dist_atten;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
index c1ce06abb7..afc6659ce7 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
@@ -31,12 +31,12 @@ out vec4 frag_color;
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect diffuseRect;
+uniform sampler2D diffuseRect;
 
 uniform mat4 inv_proj;
-uniform vec2 screen_res;
 uniform float max_cof;
 uniform float res_scale;
+uniform vec2 kern_scale;
 
 VARYING vec2 vary_fragcoord;
 
@@ -49,7 +49,7 @@ float weightByColor(vec4 s)
 
 void dofSample(inout vec4 diff, inout float w, vec2 tc)
 {
-	vec4 s = texture2DRect(diffuseRect, tc);
+	vec4 s = texture2D(diffuseRect, tc);
 
 	float sweight = weightByColor(s);
 		
@@ -63,7 +63,8 @@ void dofSample(inout vec4 diff, inout float w, vec2 tc)
 
 void main() 
 {
-  vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
+  vec2 tc = vary_fragcoord.xy;
+  vec4 diff = texture2D(diffuseRect, tc);
 	
   float w = weightByColor(diff);
   diff.rgb *= w;
@@ -81,7 +82,7 @@ void main()
 	  float ang = sc+i*2*PI/its; // sc is added for rotary perturbance
 	  float samp_x = sc*sin(ang);
 	  float samp_y = sc*cos(ang);
-	  dofSample(diff, w, vary_fragcoord.xy + vec2(samp_x,samp_y));
+	  dofSample(diff, w, tc + vec2(samp_x,samp_y) * kern_scale);
 	}
       sc -= 2.0;
     }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrectF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrectF.glsl
index 28b1e65b28..5c9e5112ca 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrectF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrectF.glsl
@@ -31,9 +31,8 @@ out vec4 frag_color;
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect diffuseRect;
+uniform sampler2D diffuseRect;
 
-uniform vec2 screen_res;
 VARYING vec2 vary_fragcoord;
 
 vec3 linear_to_srgb(vec3 cl)
@@ -58,7 +57,7 @@ vec3 linear_to_srgb(vec3 cl)
 
 void main() 
 {
-	vec4 diff = texture2DRect(diffuseRect, vary_fragcoord);
+	vec4 diff = texture2D(diffuseRect, vary_fragcoord);
 	diff.rgb = linear_to_srgb(diff.rgb);
 	frag_color = diff;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl
index a0c959a2cf..47b6774f90 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl
@@ -31,17 +31,16 @@ out vec4 frag_color;
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect diffuseRect;
+uniform sampler2D diffuseRect;
 uniform sampler2D bloomMap;
 
-uniform vec2 screen_res;
 VARYING vec2 vary_fragcoord;
 
 void main() 
 {
-	vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
+	vec4 diff = texture2D(diffuseRect, vary_fragcoord.xy);
 	
-	vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy/screen_res);
+	vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy);
 	frag_color = diff + bloom;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl
index bd0cb50464..a8465d61bb 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl
@@ -29,12 +29,10 @@ ATTRIBUTE vec3 position;
 
 VARYING vec2 vary_fragcoord;
 
-uniform vec2 screen_res;
-
 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;
+	vary_fragcoord = (pos.xy*0.5+0.5);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl
deleted file mode 100644
index 8edf5b2723..0000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl
+++ /dev/null
@@ -1,44 +0,0 @@
-/** 
- * @file postDeferredV.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$
- */
-
-uniform mat4 modelview_projection_matrix;
-
-ATTRIBUTE vec3 position;
-
-VARYING vec2 vary_fragcoord;
-VARYING vec2 vary_tc;
-
-uniform vec2 tc_scale;
-
-uniform vec2 screen_res;
-
-void main()
-{
-	//transform vertex
-	vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
-	gl_Position = pos;	
-	vary_tc = (pos.xy*0.5+0.5)*tc_scale;
-	vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
-}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
deleted file mode 100644
index 96f9628424..0000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
+++ /dev/null
@@ -1,102 +0,0 @@
-/** 
- * @file postgiF.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$
- */
-
- #ifdef DEFINE_GL_FRAGCOLOR
-out vec4 frag_color;
-#else
-#define frag_color gl_FragColor
-#endif
- 
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
-uniform sampler2DRect giLightMap;
-uniform sampler2D	noiseMap;
-
-uniform vec2 kern[32];
-uniform float dist_factor;
-uniform float blur_size;
-uniform vec2 delta;
-uniform int kern_length;
-uniform float kern_scale;
-uniform vec3 blur_quad;
-
-VARYING vec2 vary_fragcoord;
-
-uniform mat4 inv_proj;
-uniform vec2 screen_res;
-
-vec4 getPosition(vec2 pos_screen)
-{
-	float depth = texture2DRect(depthMap, pos_screen.xy).a;
-	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
-	sc -= vec2(1.0,1.0);
-	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
-	vec4 pos = inv_proj * ndc;
-	pos /= pos.w;
-	pos.w = 1.0;
-	return pos;
-}
-
-void main() 
-{
-	vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz;
-	norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
-	vec3 pos = getPosition(vary_fragcoord.xy).xyz;
-	
-	vec3 ccol = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
-	vec2 dlt = kern_scale * delta/(1.0+norm.xy*norm.xy);
-	dlt /= max(-pos.z*dist_factor, 1.0);
-	float defined_weight = kern[0].x;
-	vec3 col = vec3(0.0);
-	
-	for (int i = 0; i < kern_length; i++)
-	{
-		vec2 tc = vary_fragcoord.xy + kern[i].y*dlt;
-		vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz;
-		sampNorm = vec3((sampNorm.xy-0.5)*2.0,sampNorm.z); // unpack norm
-	    
-		float d = dot(norm.xyz, sampNorm);
-		
-		if (d > 0.8)
-		{
-			vec3 samppos = getPosition(tc.xy).xyz;
-			samppos -= pos;
-			if (dot(samppos,samppos) < -0.05*pos.z)
-			{
-	    		col += texture2DRect(giLightMap, tc).rgb*kern[i].x;
-				defined_weight += kern[i].x;
-			}
-		}
-	}
-
-	col /= defined_weight;
-	
-	//col = ccol;
-	
-	col = col*col*blur_quad.x + col*blur_quad.y + blur_quad.z;
-	
-	frag_color.rgb = col;
-}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index dda0a6eead..797a2f9667 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -32,12 +32,11 @@ out vec4 frag_color;
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect positionMap;
-uniform sampler2DRect normalMap;
-uniform sampler2DRect lightMap;
-uniform sampler2DRect depthMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D normalMap;
+uniform sampler2D lightMap;
+uniform sampler2D depthMap;
 uniform samplerCube environmentMap;
 uniform sampler2D	  lightFunc;
 
@@ -76,7 +75,6 @@ vec3 vary_AdditiveColor;
 vec3 vary_AtmosAttenuation;
 
 uniform mat4 inv_proj;
-uniform vec2 screen_res;
 
 vec3 srgb_to_linear(vec3 cs)
 {
@@ -130,7 +128,6 @@ vec3 decode_normal (vec2 enc)
 vec4 getPosition_d(vec2 pos_screen, float depth)
 {
 	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
 	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
 	vec4 pos = inv_proj * ndc;
@@ -141,7 +138,7 @@ vec4 getPosition_d(vec2 pos_screen, float depth)
 
 vec4 getPosition(vec2 pos_screen)
 { //get position in screen space (world units) given window coordinate and depth map
-	float depth = texture2DRect(depthMap, pos_screen.xy).a;
+	float depth = texture2D(depthMap, pos_screen.xy).a;
 	return getPosition_d(pos_screen, depth);
 }
 
@@ -191,7 +188,6 @@ void setAtmosAttenuation(vec3 v)
 	vary_AtmosAttenuation = v;
 }
 
-
 #ifdef WATER_FOG
 uniform vec4 waterPlane;
 uniform vec4 waterFogColor;
@@ -304,7 +300,7 @@ void calcAtmospherics(vec3 inPositionEye) {
 		vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient)
 	  + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x
 		  + tmpAmbient)));
-	
+
 	//brightness of surface both sunlight and ambient
 	setSunlitColor(vec3(sunlight * .5));
 	setAmblitColor(vec3(tmpAmbient * .25));
@@ -366,7 +362,6 @@ vec3 scaleSoftClip(vec3 light)
 	return light;
 }
 
-
 vec3 fullbrightScaleSoftClip(vec3 light)
 {
 	//soft clip effect:
@@ -376,9 +371,9 @@ vec3 fullbrightScaleSoftClip(vec3 light)
 void main() 
 {
 	vec2 tc = vary_fragcoord.xy;
-	float depth = texture2DRect(depthMap, tc.xy).r;
+	float depth = texture2D(depthMap, tc.xy).r;
 	vec3 pos = getPosition_d(tc, depth).xyz;
-	vec4 norm = texture2DRect(normalMap, tc);
+	vec4 norm = texture2D(normalMap, tc);
 	float envIntensity = norm.z;
 	norm.xyz = decode_normal(norm.xy); // unpack norm
 		
@@ -388,12 +383,12 @@ void main()
           final_da = min(final_da, 1.0f);
 	      final_da = pow(final_da, 1.0/1.3);
 
-	vec4 diffuse = texture2DRect(diffuseRect, tc);
+	vec4 diffuse = texture2D(diffuseRect, tc);
 
 	//convert to gamma space
 	diffuse.rgb = linear_to_srgb(diffuse.rgb);
 
-	vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
+	vec4 spec = texture2D(specularRect, vary_fragcoord.xy);
 	vec3 col;
 	float bloom = 0.0;
 	{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
deleted file mode 100644
index b59fcbe017..0000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
+++ /dev/null
@@ -1,40 +0,0 @@
-/** 
- * @file softenLightF.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$
- */
- 
-uniform mat4 modelview_projection_matrix;
-
-ATTRIBUTE vec3 position;
-
-uniform vec2 screen_res;
-
-VARYING vec2 vary_fragcoord;
-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/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index f57ae03be0..881dd8ed62 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -24,8 +24,6 @@
  */
 
 
-
-
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
@@ -34,10 +32,10 @@ out vec4 frag_color;
 
 //class 1 -- no shadows
 
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
 uniform samplerCube environmentMap;
 uniform sampler2D noiseMap;
 uniform sampler2D projectionMap;
@@ -64,9 +62,9 @@ uniform float falloff;
 
 VARYING vec3 trans_center;
 VARYING vec4 vary_fragcoord;
-uniform vec2 screen_res;
 
 uniform mat4 inv_proj;
+uniform vec2 noise_scale;
 
 vec2 encode_normal(vec3 n)
 {
@@ -103,25 +101,6 @@ vec3 srgb_to_linear(vec3 cs)
 
 }
 
-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));
-
-#ifdef OLD_SELECT
-	vec3 result;
-	result.r = lt.r ? low_range.r : high_range.r;
-	result.g = lt.g ? low_range.g : high_range.g;
-	result.b = lt.b ? low_range.b : high_range.b;
-    return result;
-#else
-	return mix(high_range, low_range, lt);
-#endif
-
-}
-
 vec4 correctWithGamma(vec4 col)
 {
 	return vec4(srgb_to_linear(col.rgb), col.a);
@@ -130,7 +109,7 @@ vec4 correctWithGamma(vec4 col)
 vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
 {
 	vec4 ret = texture2DLod(projectionMap, tc, lod);
-	ret.rgb = srgb_to_linear(ret.rgb);
+	ret = correctWithGamma(ret);
 	
 	vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
 	
@@ -182,9 +161,8 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
 
 vec4 getPosition(vec2 pos_screen)
 {
-	float depth = texture2DRect(depthMap, pos_screen.xy).r;
+	float depth = texture2D(depthMap, pos_screen.xy).r;
 	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
 	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
 	vec4 pos = inv_proj * ndc;
@@ -198,7 +176,6 @@ void main()
 	vec4 frag = vary_fragcoord;
 	frag.xyz /= frag.w;
 	frag.xyz = frag.xyz*0.5+0.5;
-	frag.xy *= screen_res;
 	
 	vec3 pos = getPosition(frag.xy).xyz;
 	vec3 lv = trans_center.xyz-pos.xyz;
@@ -210,7 +187,7 @@ void main()
 	}
 	
 		
-	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	vec3 norm = texture2D(normalMap, frag.xy).xyz;
 	float envIntensity = norm.z;
 	norm = decode_normal(norm.xy);
 	
@@ -241,13 +218,13 @@ void main()
 		
 	vec3 col = vec3(0,0,0);
 		
-	vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
+	vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
 		
-	vec4 spec = texture2DRect(specularRect, frag.xy);
+	vec4 spec = texture2D(specularRect, frag.xy);
 
 	
 
-	float noise = texture2D(noiseMap, frag.xy/128.0).b;
+	float noise = texture2D(noiseMap, frag.xy*noise_scale).b;
 	vec3 dlit = vec3(0, 0, 0);
 	
 	if (proj_tc.z > 0.0 &&
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightNoFragCoordV.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightNoFragCoordV.glsl
index 47e9d15fbc..e872dbf50d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightNoFragCoordV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightNoFragCoordV.glsl
@@ -27,8 +27,6 @@ uniform mat4 modelview_projection_matrix;
  
 ATTRIBUTE vec3 position;
 
-uniform vec2 screen_res;
-
 void main()
 {
 	//transform vertex
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
index cac11f8166..2b63b63489 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
@@ -33,17 +33,16 @@ out vec4 frag_color;
 
 VARYING vec2 vary_fragcoord;
 
-uniform sampler2DRect depthMapDownsampled;
-uniform sampler2DRect depthMap;
+uniform sampler2D depthMap;
 
-uniform sampler2DRect diffuseRect;
-uniform float		  downsampled_depth_scale;
-uniform vec2 screen_res;
+uniform sampler2D diffuseRect;
+
+uniform vec2 kern_scale;
 
 void main() 
 {
 	frag_color[0] = 1.0;
-    frag_color[1] = texture2DRect(diffuseRect,vary_fragcoord.xy*downsampled_depth_scale).r;
+	frag_color[1] = texture2D(diffuseRect,vary_fragcoord.xy * kern_scale).r; // Scales to handle lower-res ssao.
 	frag_color[2] = 1.0;
 	frag_color[3] = 1.0;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl
deleted file mode 100644
index 473d6df8fa..0000000000
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl
+++ /dev/null
@@ -1,41 +0,0 @@
-/** 
- * @file sunLightF.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$
- */
-
-uniform mat4 modelview_projection_matrix;
- 
-ATTRIBUTE vec3 position;
-
-VARYING vec2 vary_fragcoord;
-
-uniform vec2 screen_res;
-
-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/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 6b72e785dc..e46f73aebb 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -37,10 +37,6 @@ vec3 atmosTransport(vec3 inColor);
 uniform sampler2D bumpMap;   
 uniform sampler2D screenTex;
 uniform sampler2D refTex;
-uniform sampler2DRectShadow shadowMap0;
-uniform sampler2DRectShadow shadowMap1;
-uniform sampler2DRectShadow shadowMap2;
-uniform sampler2DRectShadow shadowMap3;
 uniform sampler2D noiseMap;
 
 uniform mat4 shadow_matrix[6];
@@ -58,7 +54,6 @@ uniform vec3 normScale;
 uniform float fresnelScale;
 uniform float fresnelOffset;
 uniform float blurMultiplier;
-uniform vec2 screen_res;
 uniform mat4 norm_mat; //region space to screen space
 
 //bigWave is (refCoord.w, view.w);
@@ -85,25 +80,6 @@ vec3 srgb_to_linear(vec3 cs)
 
 }
 
-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));
-
-#ifdef OLD_SELECT
-	vec3 result;
-	result.r = lt.r ? low_range.r : high_range.r;
-	result.g = lt.g ? low_range.g : high_range.g;
-	result.b = lt.b ? low_range.b : high_range.b;
-    return result;
-#else
-	return mix(high_range, low_range, lt);
-#endif
-
-}
-
 vec2 encode_normal(vec3 n)
 {
 	float f = sqrt(8 * n.z + 8);
diff --git a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
index a6cfb8d2b1..48886d40da 100644
--- a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
+++ b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
@@ -31,7 +31,7 @@ out vec4 frag_color;
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect diffuseMap;
+uniform sampler2D diffuseMap;
 uniform float minLuminance;
 uniform float maxExtractAlpha;
 uniform vec3 lumWeights;
@@ -42,7 +42,7 @@ VARYING vec2 vary_texcoord0;
 
 void main()
 {
-	vec4 col = texture2DRect(diffuseMap, vary_texcoord0.xy);	
+	vec4 col = texture2D(diffuseMap, vary_texcoord0.xy);	
 	/// CALCULATING LUMINANCE (Using NTSC lum weights)
 	/// http://en.wikipedia.org/wiki/Luma_%28video%29
 	float lum = smoothstep(minLuminance, minLuminance+1.0, dot(col.rgb, lumWeights ) );
diff --git a/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl b/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl
index 1396dc6973..3e6a469226 100644
--- a/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl
+++ b/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl
@@ -26,13 +26,12 @@
 uniform mat4 modelview_projection_matrix;
 
 ATTRIBUTE vec3 position;
-ATTRIBUTE vec2 texcoord0;
 
 VARYING vec2 vary_texcoord0;
 
 void main() 
 {
-	gl_Position = modelview_projection_matrix * vec4(position, 1.0);
-	
-	vary_texcoord0.xy = texcoord0;
+	vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	gl_Position = pos;	
+	vary_texcoord0 = (pos.xy*0.5+0.5);
 }
diff --git a/indra/newview/app_settings/shaders/class1/effects/glowV.glsl b/indra/newview/app_settings/shaders/class1/effects/glowV.glsl
index bde9a45370..b83c1c0074 100644
--- a/indra/newview/app_settings/shaders/class1/effects/glowV.glsl
+++ b/indra/newview/app_settings/shaders/class1/effects/glowV.glsl
@@ -26,7 +26,6 @@
 uniform mat4 modelview_projection_matrix;
 
 ATTRIBUTE vec3 position;
-ATTRIBUTE vec2 texcoord1;
 
 uniform vec2 glowDelta;
 
@@ -37,14 +36,16 @@ VARYING vec4 vary_texcoord3;
 
 void main() 
 {
-	gl_Position = modelview_projection_matrix * vec4(position, 1.0);
+	vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	gl_Position = pos;	
+	vec2 texcoord = (pos.xy*0.5+0.5);
 	
-	vary_texcoord0.xy = texcoord1 + glowDelta*(-3.5);
-	vary_texcoord1.xy = texcoord1 + glowDelta*(-2.5);
-	vary_texcoord2.xy = texcoord1 + glowDelta*(-1.5);
-	vary_texcoord3.xy = texcoord1 + glowDelta*(-0.5);
-	vary_texcoord0.zw = texcoord1 + glowDelta*(0.5);
-	vary_texcoord1.zw = texcoord1 + glowDelta*(1.5);
-	vary_texcoord2.zw = texcoord1 + glowDelta*(2.5);
-	vary_texcoord3.zw = texcoord1 + glowDelta*(3.5);
+	vary_texcoord0.xy = texcoord + glowDelta*(-3.5);
+	vary_texcoord1.xy = texcoord + glowDelta*(-2.5);
+	vary_texcoord2.xy = texcoord + glowDelta*(-1.5);
+	vary_texcoord3.xy = texcoord + glowDelta*(-0.5);
+	vary_texcoord0.zw = texcoord + glowDelta*(0.5);
+	vary_texcoord1.zw = texcoord + glowDelta*(1.5);
+	vary_texcoord2.zw = texcoord + glowDelta*(2.5);
+	vary_texcoord3.zw = texcoord + glowDelta*(3.5);
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl
deleted file mode 100644
index 6cd7d23d53..0000000000
--- a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthRectF.glsl
+++ /dev/null
@@ -1,67 +0,0 @@
-/** 
- * @file debugF.glsl
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2011, 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$
- */
-
-
-
-#ifdef DEFINE_GL_FRAGCOLOR
-out vec4 frag_color;
-#else
-#define frag_color gl_FragColor
-#endif
-
-uniform sampler2DRect depthMap;
-
-VARYING vec2 tc0;
-VARYING vec2 tc1;
-VARYING vec2 tc2;
-VARYING vec2 tc3;
-VARYING vec2 tc4;
-VARYING vec2 tc5;
-VARYING vec2 tc6;
-VARYING vec2 tc7;
-VARYING vec2 tc8;
-
-void main() 
-{
-	vec4 depth1 = 
-		vec4(texture2DRect(depthMap, tc0).r,
-			texture2DRect(depthMap, tc1).r,
-			texture2DRect(depthMap, tc2).r,
-			texture2DRect(depthMap, tc3).r);
-
-	vec4 depth2 = 
-		vec4(texture2DRect(depthMap, tc4).r,
-			texture2DRect(depthMap, tc5).r,
-			texture2DRect(depthMap, tc6).r,
-			texture2DRect(depthMap, tc7).r);
-
-	depth1 = min(depth1, depth2);
-	float depth = min(depth1.x, depth1.y);
-	depth = min(depth, depth1.z);
-	depth = min(depth, depth1.w);
-	depth = min(depth, texture2DRect(depthMap, tc8).r);
-
-	gl_FragDepth = depth;
-}
diff --git a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl
index 71d80911d6..44b6c3c855 100644
--- a/indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/downsampleDepthV.glsl
@@ -27,8 +27,6 @@ uniform mat4 modelview_projection_matrix;
 
 ATTRIBUTE vec3 position;
 
-uniform vec2 screen_res;
-
 uniform vec2 delta;
 
 VARYING vec2 tc0;
@@ -45,7 +43,7 @@ void main()
 {
 	gl_Position = vec4(position, 1.0); 
 	
-	vec2 tc = (position.xy*0.5+0.5)*screen_res;
+	vec2 tc = (position.xy*0.5+0.5);
 	tc0 = tc+vec2(-delta.x,-delta.y);
 	tc1 = tc+vec2(0,-delta.y);
 	tc2 = tc+vec2(delta.x,-delta.y);
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
index 897d9f25a6..7765b30ca7 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineF.glsl
@@ -32,13 +32,12 @@ out vec4 frag_color;
 
 
 uniform sampler2D glowMap;
-uniform sampler2DRect screenMap;
+uniform sampler2D screenMap;
 
 VARYING vec2 vary_texcoord0;
-VARYING vec2 vary_texcoord1;
 
 void main() 
 {
-	frag_color = texture2D(glowMap, vary_texcoord1.xy) +
-					texture2DRect(screenMap, vary_texcoord0.xy);
+	frag_color = texture2D(glowMap, vary_texcoord0.xy) +
+					texture2D(screenMap, vary_texcoord0.xy);
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl
index 9730f820e9..98b2a3bf0f 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAF.glsl
@@ -31,14 +31,13 @@ out vec4 frag_color;
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect diffuseRect;
+uniform sampler2D diffuseRect;
 
-uniform vec2 screen_res;
-VARYING vec2 vary_tc;
+VARYING vec2 vary_texcoord0;
 
 void main() 
 {
-	vec3 col = texture2DRect(diffuseRect, vary_tc*screen_res).rgb;
+	vec3 col = texture2D(diffuseRect, vary_texcoord0).rgb;
 	
 	frag_color = vec4(col.rgb, dot(col.rgb, vec3(0.299, 0.587, 0.144)));
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl
index 058f3b1b82..867a2d4407 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl
@@ -27,13 +27,13 @@ uniform mat4 modelview_projection_matrix;
 
 ATTRIBUTE vec3 position;
 
-VARYING vec2 vary_tc;
+VARYING vec2 vary_texcoord0;
 
 void main()
 {
 	vec4 pos = modelview_projection_matrix*vec4(position.xyz, 1.0);
 	gl_Position = pos;
 
-	vary_tc = pos.xy*0.5+0.5;
+	vary_texcoord0 = pos.xy*0.5+0.5;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl
index f7970b7f78..83e728ce3b 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl
@@ -26,16 +26,13 @@
 uniform mat4 modelview_projection_matrix;
 
 ATTRIBUTE vec3 position;
-ATTRIBUTE vec2 texcoord0;
-ATTRIBUTE vec2 texcoord1;
 
 VARYING vec2 vary_texcoord0;
-VARYING vec2 vary_texcoord1;
 
 void main()
 {
-	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
-	vary_texcoord0 = texcoord0;
-	vary_texcoord1 = texcoord1;
+	vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	gl_Position = pos;	
+	vary_texcoord0 = (pos.xy*0.5+0.5);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl b/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl
index a0c797f3ee..468cf480dd 100644
--- a/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/splattexturerectF.glsl
@@ -31,12 +31,12 @@ out vec4 frag_color;
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect screenMap;
+uniform sampler2D screenMap;
 
 VARYING vec4 vertex_color;
 VARYING vec2 vary_texcoord0;
 
 void main() 
 {
-	frag_color = 	texture2DRect(screenMap, vary_texcoord0.xy) * vertex_color;
+	frag_color = 	texture2D(screenMap, vary_texcoord0.xy) * vertex_color;
 }
diff --git a/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl b/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl
deleted file mode 100644
index 5af9f5c902..0000000000
--- a/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl
+++ /dev/null
@@ -1,62 +0,0 @@
-/** 
- * @file eyeballV.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$
- */
-
-uniform mat3 normal_matrix;
-uniform mat4 texture_matrix0;
-uniform mat4 modelview_matrix;
-uniform mat4 modelview_projection_matrix;
-
-ATTRIBUTE vec3 position;
-ATTRIBUTE vec4 diffuse_color;
-ATTRIBUTE vec3 normal;
-ATTRIBUTE vec2 texcoord0;
-
-VARYING vec4 vertex_color;
-VARYING vec2 vary_texcoord0;
-
-
-vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol);
-void calcAtmospherics(vec3 inPositionEye);
-
-void main()
-{
-	//transform vertex
-	vec3 pos = (modelview_matrix * vec4(position.xyz, 1.0)).xyz;
-	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
-	vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
-		
-	vec3 norm = normalize(normal_matrix * normal);
-
-	calcAtmospherics(pos.xyz);
-	
-	// vec4 specular = specularColor;
-	vec4 specular = vec4(1.0);
-	vec4 color = calcLightingSpecular(pos, norm, diffuse_color, specular, vec4(0.0));
-			
-	vertex_color = color;
-	
-
-}
-
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 74a17f3bb7..8afdd95f44 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -24,20 +24,18 @@
  */
  
 
-
-
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
 uniform samplerCube environmentMap;
-uniform sampler2DRect lightMap;
+uniform sampler2D lightMap;
 uniform sampler2D noiseMap;
 uniform sampler2D projectionMap;
 uniform sampler2D lightFunc;
@@ -65,46 +63,10 @@ uniform vec3 color;
 uniform float falloff;
 
 VARYING vec4 vary_fragcoord;
-uniform vec2 screen_res;
 
 uniform mat4 inv_proj;
+uniform vec2 noise_scale;
 
-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));
-
-#ifdef OLD_SELECT
-	vec3 result;
-	result.r = lte.r ? low_range.r : high_range.r;
-	result.g = lte.g ? low_range.g : high_range.g;
-	result.b = lte.b ? low_range.b : high_range.b;
-    return result;
-#else
-	return mix(high_range, low_range, lte);
-#endif
-
-}
-
-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));
-
-#ifdef OLD_SELECT
-	vec3 result;
-	result.r = lt.r ? low_range.r : high_range.r;
-	result.g = lt.g ? low_range.g : high_range.g;
-	result.b = lt.b ? low_range.b : high_range.b;
-    return result;
-#else
-	return mix(high_range, low_range, lt);
-#endif
-
-}
 
 vec2 encode_normal(vec3 n)
 {
@@ -123,9 +85,22 @@ vec3 decode_normal (vec2 enc)
     return n;
 }
 
-vec4 correctWithGamma(vec4 col)
+vec3 srgb_to_linear(vec3 cs)
 {
-	return vec4(srgb_to_linear(col.rgb), col.a);
+	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));
+
+#ifdef OLD_SELECT
+	vec3 result;
+	result.r = lte.r ? low_range.r : high_range.r;
+	result.g = lte.g ? low_range.g : high_range.g;
+	result.b = lte.b ? low_range.b : high_range.b;
+    return result;
+#else
+	return mix(high_range, low_range, lte);
+#endif
+
 }
 
 vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
@@ -151,7 +126,7 @@ 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);
+	ret.rgb = srgb_to_linear(ret.rgb);
 
 	vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
 	
@@ -169,8 +144,8 @@ 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);
-
+	ret.rgb = srgb_to_linear(ret.rgb);
+	
 	vec2 dist = tc-vec2(0.5);
 	
 	float d = dot(dist,dist);
@@ -183,9 +158,8 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
 
 vec4 getPosition(vec2 pos_screen)
 {
-	float depth = texture2DRect(depthMap, pos_screen.xy).r;
+	float depth = texture2D(depthMap, pos_screen.xy).r;
 	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
 	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
 	vec4 pos = inv_proj * ndc;
@@ -199,7 +173,6 @@ void main()
 	vec4 frag = vary_fragcoord;
 	frag.xyz /= frag.w;
 	frag.xyz = frag.xyz*0.5+0.5;
-	frag.xy *= screen_res;
 	
 	vec3 pos = getPosition(frag.xy).xyz;
 	vec3 lv = center.xyz-pos.xyz;
@@ -214,14 +187,14 @@ void main()
 	
 	if (proj_shadow_idx >= 0)
 	{
-		vec4 shd = texture2DRect(lightMap, frag.xy);
+		vec4 shd = texture2D(lightMap, frag.xy);
 		float sh[2];
 		sh[0] = shd.b;
 		sh[1] = shd.a;
 		shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0);
 	}
 	
-	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	vec3 norm = texture2D(normalMap, frag.xy).xyz;
 	
 	float envIntensity = norm.z;
 
@@ -242,6 +215,7 @@ void main()
 	float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0);
 	dist_atten *= dist_atten;
 	dist_atten *= 2.0;
+
 	if (dist_atten <= 0.0)
 	{
 		discard;
@@ -253,13 +227,10 @@ void main()
 
 	vec3 col = vec3(0,0,0);
 		
-	vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
-	
-	vec4 spec = texture2DRect(specularRect, frag.xy);
-
+	vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
 	vec3 dlit = vec3(0, 0, 0);
 
-	float noise = texture2D(noiseMap, frag.xy/128.0).b;
+	float noise = texture2D(noiseMap, frag.xy*noise_scale).b;
 	if (proj_tc.z > 0.0 &&
 		proj_tc.x < 1.0 &&
 		proj_tc.y < 1.0 &&
@@ -295,8 +266,9 @@ void main()
 			
 		col += amb_da*color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a;
 	}
-	
 
+	vec4 spec = texture2D(specularRect, frag.xy);
+	
 	if (spec.a > 0.0)
 	{
 		vec3 npos = -normalize(pos);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 1cbb53ce18..614e2c5c58 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -31,11 +31,11 @@ out vec4 frag_color;
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect normalMap;
-uniform sampler2DRect lightMap;
-uniform sampler2DRect depthMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D normalMap;
+uniform sampler2D lightMap;
+uniform sampler2D depthMap;
 uniform samplerCube environmentMap;
 uniform sampler2D	  lightFunc;
 
@@ -76,7 +76,6 @@ vec3 vary_AdditiveColor;
 vec3 vary_AtmosAttenuation;
 
 uniform mat4 inv_proj;
-uniform vec2 screen_res;
 
 vec3 srgb_to_linear(vec3 cs)
 {
@@ -135,7 +134,6 @@ vec3 decode_normal (vec2 enc)
 vec4 getPosition_d(vec2 pos_screen, float depth)
 {
 	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
 	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
 	vec4 pos = inv_proj * ndc;
@@ -146,7 +144,7 @@ vec4 getPosition_d(vec2 pos_screen, float depth)
 
 vec4 getPosition(vec2 pos_screen)
 { //get position in screen space (world units) given window coordinate and depth map
-	float depth = texture2DRect(depthMap, pos_screen.xy).r;
+	float depth = texture2D(depthMap, pos_screen.xy).r;
 	return getPosition_d(pos_screen, depth);
 }
 
@@ -256,7 +254,7 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) {
 	
 	//increase ambient when there are more clouds
 	vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5;
-	
+
 	//haze color
 	setAdditiveColor(
 		vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient)
@@ -387,9 +385,9 @@ vec3 fullbrightScaleSoftClip(vec3 light)
 void main() 
 {
 	vec2 tc = vary_fragcoord.xy;
-	float depth = texture2DRect(depthMap, tc.xy).r;
+	float depth = texture2D(depthMap, tc.xy).r;
 	vec3 pos = getPosition_d(tc, depth).xyz;
-	vec4 norm = texture2DRect(normalMap, tc);
+	vec4 norm = texture2D(normalMap, tc);
 	float envIntensity = norm.z;
 	norm.xyz = decode_normal(norm.xy); // unpack norm
 		
@@ -399,7 +397,7 @@ void main()
 	da = pow(da, light_gamma);
 
 
-	vec4 diffuse = texture2DRect(diffuseRect, tc);
+	vec4 diffuse = texture2D(diffuseRect, tc);
 
 	//convert to gamma space
 	diffuse.rgb = linear_to_srgb(diffuse.rgb);
@@ -407,9 +405,9 @@ void main()
 	vec3 col;
 	float bloom = 0.0;
 	{
-		vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
+		vec4 spec = texture2D(specularRect, vary_fragcoord.xy);
 		
-		vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
+		vec2 scol_ambocc = texture2D(lightMap, vary_fragcoord.xy).rg;
 		scol_ambocc = pow(scol_ambocc, vec2(light_gamma));
 
 		float scol = max(scol_ambocc.r, diffuse.a); 
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
deleted file mode 100644
index c840d72784..0000000000
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
+++ /dev/null
@@ -1,42 +0,0 @@
-/** 
- * @file softenLightF.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$
- */
-
-uniform mat4 modelview_projection_matrix;
-
-ATTRIBUTE vec3 position;
-
-uniform vec2 screen_res;
-
-VARYING vec2 vary_fragcoord;
-
-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 474d8e5b3e..0fa123cce1 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -24,20 +24,18 @@
  */
  
 
-
-
 #ifdef DEFINE_GL_FRAGCOLOR
 out vec4 frag_color;
 #else
 #define frag_color gl_FragColor
 #endif
 
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect specularRect;
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D specularRect;
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
 uniform samplerCube environmentMap;
-uniform sampler2DRect lightMap;
+uniform sampler2D lightMap;
 uniform sampler2D noiseMap;
 uniform sampler2D projectionMap;
 uniform sampler2D lightFunc;
@@ -65,9 +63,9 @@ uniform float falloff;
 
 VARYING vec3 trans_center;
 VARYING vec4 vary_fragcoord;
-uniform vec2 screen_res;
 
 uniform mat4 inv_proj;
+uniform vec2 noise_scale;
 
 vec2 encode_normal(vec3 n)
 {
@@ -183,9 +181,8 @@ vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
 
 vec4 getPosition(vec2 pos_screen)
 {
-	float depth = texture2DRect(depthMap, pos_screen.xy).r;
+	float depth = texture2D(depthMap, pos_screen.xy).r;
 	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
 	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
 	vec4 pos = inv_proj * ndc;
@@ -199,7 +196,6 @@ void main()
 	vec4 frag = vary_fragcoord;
 	frag.xyz /= frag.w;
 	frag.xyz = frag.xyz*0.5+0.5;
-	frag.xy *= screen_res;
 	
 	vec3 pos = getPosition(frag.xy).xyz;
 	vec3 lv = trans_center.xyz-pos.xyz;
@@ -214,14 +210,14 @@ void main()
 	
 	if (proj_shadow_idx >= 0)
 	{
-		vec4 shd = texture2DRect(lightMap, frag.xy);
+		vec4 shd = texture2D(lightMap, frag.xy);
 		float sh[2];
 		sh[0] = shd.b;
 		sh[1] = shd.a;
 		shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0);
 	}
 	
-	vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
+	vec3 norm = texture2D(normalMap, frag.xy).xyz;
 	float envIntensity = norm.z;
 	norm = decode_normal(norm.xy);
 	
@@ -252,13 +248,13 @@ void main()
 		
 	vec3 col = vec3(0,0,0);
 		
-	vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
+	vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
 		
-	vec4 spec = texture2DRect(specularRect, frag.xy);
+	vec4 spec = texture2D(specularRect, frag.xy);
 
+	float noise = texture2D(noiseMap, frag.xy*noise_scale).b;
 	vec3 dlit = vec3(0, 0, 0);
 
-	float noise = texture2D(noiseMap, frag.xy/128.0).b;
 	if (proj_tc.z > 0.0 &&
 		proj_tc.x < 1.0 &&
 		proj_tc.y < 1.0 &&
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index df8cb97c4f..3aeff0d215 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -33,8 +33,8 @@ out vec4 frag_color;
 
 //class 2, shadows, no SSAO
 
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
 uniform sampler2DShadow shadowMap0;
 uniform sampler2DShadow shadowMap1;
 uniform sampler2DShadow shadowMap2;
@@ -54,7 +54,6 @@ uniform float ssao_factor_inv;
 VARYING vec2 vary_fragcoord;
 
 uniform mat4 inv_proj;
-uniform vec2 screen_res;
 uniform vec2 proj_shadow_res;
 uniform vec3 sun_dir;
 
@@ -84,9 +83,8 @@ vec3 decode_normal (vec2 enc)
 
 vec4 getPosition(vec2 pos_screen)
 {
-	float depth = texture2DRect(depthMap, pos_screen.xy).r;
+	float depth = texture2D(depthMap, pos_screen.xy).r;
 	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
 	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
 	vec4 pos = inv_proj * ndc;
@@ -142,7 +140,7 @@ void main()
 	
 	vec4 pos = getPosition(pos_screen);
 	
-	vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
+	vec3 norm = texture2D(normalMap, pos_screen).xyz;
 	norm = decode_normal(norm.xy); // unpack norm
 		
 	/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
@@ -153,7 +151,7 @@ void main()
 	
 	float shadow = 0.0;
 	float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz));
-	
+
 	vec3 shadow_pos = pos.xyz;
 	vec3 offset = sun_dir.xyz * (1.0-dp_directional_light);
 	
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
index d065181067..ac8da77ea1 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
@@ -32,9 +32,9 @@ out vec4 frag_color;
 
 //class 2 -- shadows and SSAO
 
-uniform sampler2DRect diffuseRect;
-uniform sampler2DRect depthMap;
-uniform sampler2DRect normalMap;
+uniform sampler2D diffuseRect;
+uniform sampler2D depthMap;
+uniform sampler2D normalMap;
 uniform sampler2DShadow shadowMap0;
 uniform sampler2DShadow shadowMap1;
 uniform sampler2DShadow shadowMap2;
@@ -50,8 +50,9 @@ uniform vec4 shadow_clip;
 
 VARYING vec2 vary_fragcoord;
 
+uniform vec2 kern_scale;
+
 uniform mat4 inv_proj;
-uniform vec2 screen_res;
 uniform vec2 proj_shadow_res;
 uniform vec3 sun_dir;
 
@@ -63,7 +64,6 @@ uniform float shadow_offset;
 uniform float spot_shadow_bias;
 uniform float spot_shadow_offset;
 
-uniform float		  downsampled_depth_scale;
 
 vec2 encode_normal(vec3 n)
 {
@@ -84,9 +84,8 @@ vec3 decode_normal (vec2 enc)
 
 vec4 getPosition(vec2 pos_screen)
 {
-	float depth = texture2DRect(depthMap, pos_screen.xy).r;
+	float depth = texture2D(depthMap, pos_screen.xy).r;
 	vec2 sc = pos_screen.xy*2.0;
-	sc /= screen_res;
 	sc -= vec2(1.0,1.0);
 	vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
 	vec4 pos = inv_proj * ndc;
@@ -141,7 +140,7 @@ void main()
 	
 	vec4 pos = getPosition(pos_screen);
 	
-	vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
+	vec3 norm = texture2D(normalMap, pos_screen).xyz;
 	norm = decode_normal(norm.xy); // unpack norm
 		
 	/*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
@@ -242,7 +241,7 @@ void main()
 	}
 	
 	frag_color[0] = shadow;
-	frag_color[1] = texture2DRect(diffuseRect,vary_fragcoord*downsampled_depth_scale).r;
+	frag_color[1] = texture2D(diffuseRect,vary_fragcoord.xy * kern_scale).r;
 	
 	spos = vec4(shadow_pos+norm*spot_shadow_offset, 1.0);
 	
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl
deleted file mode 100644
index bc5eb5181d..0000000000
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl
+++ /dev/null
@@ -1,41 +0,0 @@
-/** 
- * @file sunLightV.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$
- */
-
-uniform mat4 modelview_projection_matrix;
-
-ATTRIBUTE vec3 position;
-
-VARYING vec2 vary_fragcoord;
-
-uniform vec2 screen_res;
-
-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/lighting/sumLightsSpecularV.glsl b/indra/newview/app_settings/shaders/class2/lighting/sumLightsSpecularV.glsl
index 3acf9fe883..5a02722609 100644
--- a/indra/newview/app_settings/shaders/class2/lighting/sumLightsSpecularV.glsl
+++ b/indra/newview/app_settings/shaders/class2/lighting/sumLightsSpecularV.glsl
@@ -1,5 +1,5 @@
 /**
- * @file sumLightsV.glsl
+ * @file sumLightsSpecularV.glsl
  *
  * $LicenseInfo:firstyear=2005&license=viewerlgpl$
  * Second Life Viewer Source Code
diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl
index d174805cc0..da3d922017 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl
@@ -129,7 +129,7 @@ void calcAtmospherics(vec3 inPositionEye) {
 		vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient)
 	  + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x
 		  + tmpAmbient)));
-	
+
 	//brightness of surface both sunlight and ambient
 	setSunlitColor(vec3(sunlight * .5));
 	setAmblitColor(vec3(tmpAmbient * .25));
diff --git a/indra/newview/app_settings/shaders/shader_hierarchy.txt b/indra/newview/app_settings/shaders/shader_hierarchy.txt
index d8bbf69b38..2ce76d731e 100644
--- a/indra/newview/app_settings/shaders/shader_hierarchy.txt
+++ b/indra/newview/app_settings/shaders/shader_hierarchy.txt
@@ -18,25 +18,6 @@ avatar/avatarF.glsl - gAvatarProgram
 				atmosLighting() - windlight/atmosphericsF.glsl
 				scaleSoftClip() - windlight/gammaF.glsl
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-avatar/eyeballV.glsl - gAvatarEyeballProgram
-	main() - avatar/eyeballV.glsl
-		calcAtmospherics() - windlight/atmosphericsV.glsl
-		calcLightingSpecular() - lighting/lightSpecularV.glsl
-			sumLightsSpecular() - lighting/sumLightsSpecularV.glsl
-				calcDirectionalLightSpecular() - lighting/lightFuncSpecularV.glsl
-				calcPointLightSpecular() - lighting/lightFuncSpecularV.glsl
-				atmosAmbient() - windlight/atmosphericsHelpersV.glsl
-				atmosAffectDirectionalLight() - windlight/atmosphericsHelpersV.glsl
-				atmosGetDiffuseSunlightColor() - windlight/atmosphericsHelpersV.glsl
-				scaleDownLight() - windlight/atmosphericsHelpersV.glsl
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-avatar/eyeballF.glsl - gAvatarEyeballProgram
-	main() - avatar/eyeballF.glsl
-		default_lighting() - lighting/lightF.glsl
-			calc_default_lighting() - lighting/lightF.glsl
-				atmosLighting() - windlight/atmosphericsF.glsl
-				scaleSoftClip() - windlight/gammaF.glsl
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 avatar/pickAvatarV.glsl - gAvatarPickProgram
 	main() - avatar/pickAvatarV.glsl
 		getSkinnedTransform() - avatarSkinV.glsl
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 297bc4e37c..706fae5f75 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -616,7 +616,7 @@ void LLDrawPoolWater::shade()
 		1.f/gGLViewport[2],
 		1.f/gGLViewport[3]
 	};
-	shader->uniform2fv(LLShaderMgr::DEFERRED_SCREEN_RES, 1, screenRes);
+
 	stop_glerror();
 	
 	S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP);
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 3dbcb941fb..e0dce60e55 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -81,7 +81,6 @@ LLGLSLShader	gOneTextureNoColorProgram;
 LLGLSLShader	gDebugProgram;
 LLGLSLShader	gClipProgram;
 LLGLSLShader	gDownsampleDepthProgram;
-LLGLSLShader	gDownsampleDepthRectProgram;
 LLGLSLShader	gAlphaMaskProgram;
 LLGLSLShader	gBenchmarkProgram;
 
@@ -153,7 +152,6 @@ LLGLSLShader		gHighlightSpecularProgram;
 //avatar shader handles
 LLGLSLShader		gAvatarProgram;
 LLGLSLShader		gAvatarWaterProgram;
-LLGLSLShader		gAvatarEyeballProgram;
 LLGLSLShader		gAvatarPickProgram;
 LLGLSLShader		gImpostorProgram;
 
@@ -238,7 +236,6 @@ LLViewerShaderMgr::LLViewerShaderMgr() :
 	mShaderList.push_back(&gObjectShinyProgram);
 	mShaderList.push_back(&gObjectShinyNonIndexedProgram);
 	mShaderList.push_back(&gWaterProgram);
-	mShaderList.push_back(&gAvatarEyeballProgram); 
 	mShaderList.push_back(&gObjectSimpleProgram);
 	mShaderList.push_back(&gObjectSimpleImpostorProgram);
 	mShaderList.push_back(&gObjectPreviewProgram);
@@ -677,7 +674,6 @@ void LLViewerShaderMgr::unloadShaders()
 	gDebugProgram.unload();
 	gClipProgram.unload();
 	gDownsampleDepthProgram.unload();
-	gDownsampleDepthRectProgram.unload();
 	gBenchmarkProgram.unload();
 	gAlphaMaskProgram.unload();
 	gUIProgram.unload();
@@ -754,7 +750,6 @@ void LLViewerShaderMgr::unloadShaders()
 	gGlowExtractProgram.unload();
 	gAvatarProgram.unload();
 	gAvatarWaterProgram.unload();
-	gAvatarEyeballProgram.unload();
 	gAvatarPickProgram.unload();
 	gHighlightProgram.unload();
 	gHighlightNormalProgram.unload();
@@ -1426,7 +1421,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 	if (success)
 	{
 		std::string fragment;
-		std::string vertex = "deferred/sunLightV.glsl";
+		std::string vertex = "deferred/postDeferredNoTCV.glsl";
 
 		if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
 		{
@@ -1456,7 +1451,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		{
 			gDeferredSSAOProgram.mName = "Deferred Ambient Occlusion Shader";
 			gDeferredSSAOProgram.mShaderFiles.clear();
-			gDeferredSSAOProgram.mShaderFiles.push_back(std::make_pair("deferred/sunLightV.glsl", GL_VERTEX_SHADER_ARB));
+			gDeferredSSAOProgram.mShaderFiles.push_back(std::make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
 			gDeferredSSAOProgram.mShaderFiles.push_back(std::make_pair("deferred/SSAOF.glsl", GL_FRAGMENT_SHADER_ARB));
 			gDeferredSSAOProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 			success = gDeferredSSAOProgram.createShader(NULL, NULL);
@@ -1466,7 +1461,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		{
 			gDeferredDownsampleDepthNearestProgram.mName = "Deferred Nearest Downsample Depth Shader";
 			gDeferredDownsampleDepthNearestProgram.mShaderFiles.clear();
-			gDeferredDownsampleDepthNearestProgram.mShaderFiles.push_back(std::make_pair("deferred/sunLightV.glsl", GL_VERTEX_SHADER_ARB));
+			gDeferredDownsampleDepthNearestProgram.mShaderFiles.push_back(std::make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
 			gDeferredDownsampleDepthNearestProgram.mShaderFiles.push_back(std::make_pair("deferred/downsampleDepthNearestF.glsl", GL_FRAGMENT_SHADER_ARB));
 			gDeferredDownsampleDepthNearestProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 			success = gDeferredDownsampleDepthNearestProgram.createShader(NULL, NULL);
@@ -1477,7 +1472,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 	{
 		gDeferredBlurLightProgram.mName = "Deferred Blur Light Shader";
 		gDeferredBlurLightProgram.mShaderFiles.clear();
-		gDeferredBlurLightProgram.mShaderFiles.push_back(std::make_pair("deferred/blurLightV.glsl", GL_VERTEX_SHADER));
+		gDeferredBlurLightProgram.mShaderFiles.push_back(std::make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER));
 		gDeferredBlurLightProgram.mShaderFiles.push_back(std::make_pair("deferred/blurLightF.glsl", GL_FRAGMENT_SHADER));
 		gDeferredBlurLightProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 
@@ -1748,7 +1743,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 	{
 		gDeferredSoftenProgram.mName = "Deferred Soften Shader";
 		gDeferredSoftenProgram.mShaderFiles.clear();
-		gDeferredSoftenProgram.mShaderFiles.push_back(std::make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER));
+		gDeferredSoftenProgram.mShaderFiles.push_back(std::make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER));
 		gDeferredSoftenProgram.mShaderFiles.push_back(std::make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER));
 		gDeferredSoftenProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
 
@@ -1764,7 +1759,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 	{
 		gDeferredSoftenWaterProgram.mName = "Deferred Soften Underwater Shader";
 		gDeferredSoftenWaterProgram.mShaderFiles.clear();
-		gDeferredSoftenWaterProgram.mShaderFiles.push_back(std::make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER));
+		gDeferredSoftenWaterProgram.mShaderFiles.push_back(std::make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER));
 		gDeferredSoftenWaterProgram.mShaderFiles.push_back(std::make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER));
 
 		gDeferredSoftenWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
@@ -1895,7 +1890,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 	{
 		gFXAAProgram.mName = "FXAA Shader";
 		gFXAAProgram.mShaderFiles.clear();
-		gFXAAProgram.mShaderFiles.push_back(std::make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER));
+		gFXAAProgram.mShaderFiles.push_back(std::make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER));
 		gFXAAProgram.mShaderFiles.push_back(std::make_pair("deferred/fxaaF.glsl", GL_FRAGMENT_SHADER));
 		gFXAAProgram.addPermutation("FXAA_QUALITY_PRESET", std::to_string(gSavedSettings.getU32("RenderDeferredFXAAQuality"))); // <alchemy/>
 		gFXAAProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
@@ -2888,7 +2883,6 @@ BOOL LLViewerShaderMgr::loadShadersAvatar()
 	{
 		gAvatarProgram.unload();
 		gAvatarWaterProgram.unload();
-		gAvatarEyeballProgram.unload();
 		gAvatarPickProgram.unload();
 		return TRUE;
 	}
@@ -2949,24 +2943,6 @@ BOOL LLViewerShaderMgr::loadShadersAvatar()
 		success = gAvatarPickProgram.createShader(NULL, NULL);
 	}
 
-	if (success)
-	{
-		gAvatarEyeballProgram.mName = "Avatar Eyeball Program";
-		gAvatarEyeballProgram.mFeatures.calculatesLighting = true;
-		gAvatarEyeballProgram.mFeatures.isSpecular = true;
-		gAvatarEyeballProgram.mFeatures.calculatesAtmospherics = true;
-		gAvatarEyeballProgram.mFeatures.hasGamma = true;
-		gAvatarEyeballProgram.mFeatures.hasAtmospherics = true;
-		gAvatarEyeballProgram.mFeatures.hasLighting = true;
-		gAvatarEyeballProgram.mFeatures.hasAlphaMask = true;
-		gAvatarEyeballProgram.mFeatures.disableTextureIndex = true;
-		gAvatarEyeballProgram.mShaderFiles.clear();
-		gAvatarEyeballProgram.mShaderFiles.push_back(std::make_pair("avatar/eyeballV.glsl", GL_VERTEX_SHADER));
-		gAvatarEyeballProgram.mShaderFiles.push_back(std::make_pair("avatar/eyeballF.glsl", GL_FRAGMENT_SHADER));
-		gAvatarEyeballProgram.mShaderLevel = mVertexShaderLevel[SHADER_AVATAR];
-		success = gAvatarEyeballProgram.createShader(NULL, NULL);
-	}
-
 	if( !success )
 	{
 		mVertexShaderLevel[SHADER_AVATAR] = 0;
@@ -3219,16 +3195,6 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
 		success = gDownsampleDepthProgram.createShader(NULL, NULL);
 	}
 
-	if (success)
-	{
-		gDownsampleDepthRectProgram.mName = "DownsampleDepthRect Shader";
-		gDownsampleDepthRectProgram.mShaderFiles.clear();
-		gDownsampleDepthRectProgram.mShaderFiles.push_back(std::make_pair("interface/downsampleDepthV.glsl", GL_VERTEX_SHADER));
-		gDownsampleDepthRectProgram.mShaderFiles.push_back(std::make_pair("interface/downsampleDepthRectF.glsl", GL_FRAGMENT_SHADER));
-		gDownsampleDepthRectProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE];
-		success = gDownsampleDepthRectProgram.createShader(NULL, NULL);
-	}
-
 	if (success)
 	{
 		gBenchmarkProgram.mName = "Benchmark Shader";
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index f6bd7264c2..03ac4d2147 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -172,7 +172,6 @@ extern LLGLSLShader			gGlowCombineFXAAProgram;
 extern LLGLSLShader			gDebugProgram;
 extern LLGLSLShader			gClipProgram;
 extern LLGLSLShader			gDownsampleDepthProgram;
-extern LLGLSLShader			gDownsampleDepthRectProgram;
 extern LLGLSLShader			gBenchmarkProgram;
 
 //output tex0[tc0] + tex1[tc1]
@@ -256,7 +255,6 @@ extern LLGLSLShader			gHighlightSpecularProgram;
 // avatar shader handles
 extern LLGLSLShader			gAvatarProgram;
 extern LLGLSLShader			gAvatarWaterProgram;
-extern LLGLSLShader			gAvatarEyeballProgram;
 extern LLGLSLShader			gAvatarPickProgram;
 extern LLGLSLShader			gImpostorProgram;
 
@@ -284,7 +282,7 @@ extern LLGLSLShader			gDeferredLightProgram;
 extern LLGLSLShader			gDeferredMultiLightProgram[LL_DEFERRED_MULTI_LIGHT_COUNT];
 extern LLGLSLShader			gDeferredSpotLightProgram;
 extern LLGLSLShader			gDeferredMultiSpotLightProgram;
-extern LLGLSLShader			gDeferredSSAOProgram;
+extern LLGLSLShader			gDeferredSSAOProgram;
 extern LLGLSLShader			gDeferredDownsampleDepthNearestProgram;
 extern LLGLSLShader			gDeferredSunProgram;
 extern LLGLSLShader			gDeferredBlurLightProgram;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index c5b6d86a64..75cf47f680 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -219,6 +219,7 @@ LLTrace::EventStatHandle<S64> LLPipeline::sStatBatchSize("renderbatchsize");
 
 const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f;
 const F32 BACKLIGHT_NIGHT_MAGNITUDE_OBJECT = 0.08f;
+const U32 NOISE_MAP_RES = 256;
 const U32 AUX_VB_MASK = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1;
 
 extern S32 gBoxFrame;
@@ -266,18 +267,9 @@ LLTrace::BlockTimerStatHandle FTM_RENDER_DEFERRED("Deferred Shading");
 
 static LLTrace::BlockTimerStatHandle FTM_STATESORT_DRAWABLE("Sort Drawables");
 static LLTrace::BlockTimerStatHandle FTM_STATESORT_POSTSORT("Post Sort");
-static LLTrace::BlockTimerStatHandle FTM_TRANSFORM_WAIT("Transform Fence");
-static LLTrace::BlockTimerStatHandle FTM_TRANSFORM_DO_WORK("Transform Work");
-
-static LLStaticHashedString sTint("tint");
-static LLStaticHashedString sAmbiance("ambiance");
-static LLStaticHashedString sAlphaScale("alpha_scale");
-static LLStaticHashedString sNormMat("norm_mat");
-static LLStaticHashedString sScreenRes("screenRes");
+
 static LLStaticHashedString sDelta("delta");
 static LLStaticHashedString sDistFactor("dist_factor");
-static LLStaticHashedString sKern("kern");
-static LLStaticHashedString sKernScale("kern_scale");
 
 //----------------------------------------
 std::string gPoolNames[] = 
@@ -446,7 +438,6 @@ LLPipeline::LLPipeline() :
 	mScreenHeight(0)
 {
 	mNoiseMap = 0;
-	mTrueNoiseMap = 0;
 	mLightFunc = 0;
 }
 
@@ -800,7 +791,7 @@ void LLPipeline::allocatePhysicsBuffer()
 
 	if (mPhysicsDisplay.getWidth() != resX || mPhysicsDisplay.getHeight() != resY)
 	{
-		mPhysicsDisplay.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE);
+		mPhysicsDisplay.allocate(resX, resY, GL_RGBA, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE);
 	}
 }
 
@@ -913,7 +904,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
 
 	if (RenderUIBuffer)
 	{
-		if (!mUIScreen.allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE))
+		if (!mUIScreen.allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE))
 		{
 			return false;
 		}
@@ -925,8 +916,8 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
 		BOOL ssao = RenderDeferredSSAO;
 		
 		//allocate deferred rendering color buffers
-		if (!mDeferredScreen.allocate(resX, resY, GL_SRGB8_ALPHA8, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false;
-		if (!mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false;
+		if (!mDeferredScreen.allocate(resX, resY, GL_SRGB8_ALPHA8, TRUE, TRUE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false;
+		if (!mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false;
 		if (!addDeferredAttachments(mDeferredScreen)) return false;
 	
 		GLuint screenFormat = GL_RGBA16;
@@ -940,8 +931,8 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
 			screenFormat = GL_RGBA16F_ARB;
 		}
         
-		if (!mScreen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false;
-		if (!mFinalScreen.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false;
+		if (!mScreen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false;
+		if (!mFinalScreen.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false;
 		if (samples > 0)
 		{
 			if (!mFXAABuffer.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false;
@@ -953,11 +944,11 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
 		
 		if (shadow_detail > 0 || ssao || RenderDepthOfField || samples > 0)
 		{ //only need mDeferredLight for shadows OR ssao OR dof OR fxaa
-			if (!mDeferredLight.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
+			if (!mDeferredLight.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE)) return false;
 			if(ssao)
 			{
 				F32 scale = llclamp(RenderDeferredSSAOResolutionScale, 0.01f, 1.f);
-				if( scale < 1.f && !mDeferredDownsampledDepth.allocate(llceil(F32(resX)*scale), llceil(F32(resY)*scale), 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE) ) return false;
+				if( scale < 1.f && !mDeferredDownsampledDepth.allocate(llceil(F32(resX)*scale), llceil(F32(resY)*scale), 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE, FALSE) ) return false;
 			}
 		}
 		else
@@ -1023,7 +1014,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
 		mDeferredDepth.release();
 		mDeferredDownsampledDepth.release();
 						
-		if (!mScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;		
+		if (!mScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_TEXTURE, FALSE)) return false;		
 	}
 	
 	if (LLPipeline::sRenderDeferred)
@@ -1172,12 +1163,6 @@ void LLPipeline::releaseGLBuffers()
 		mNoiseMap = 0;
 	}
 
-	if (mTrueNoiseMap)
-	{
-		LLImageGL::deleteTextures(1, &mTrueNoiseMap);
-		mTrueNoiseMap = 0;
-	}
-
 	releaseLUTBuffers();
 
 	mWaterRef.release();
@@ -1289,38 +1274,23 @@ void LLPipeline::createGLBuffers()
 	{
 		if (!mNoiseMap)
 		{
-			const U32 noiseRes = 128;
-			LLVector3 noise[noiseRes*noiseRes];
+			LLVector3 noise[NOISE_MAP_RES*NOISE_MAP_RES];
 
 			F32 scaler = gSavedSettings.getF32("RenderDeferredNoise")/100.f;
-			for (U32 i = 0; i < noiseRes*noiseRes; ++i)
+			for (auto& val : noise)
 			{
-				noise[i] = LLVector3(ll_frand()-0.5f, ll_frand()-0.5f, 0.f);
-				noise[i].normVec();
-				noise[i].mV[2] = ll_frand()*scaler+1.f-scaler/2.f;
+				val = LLVector3(ll_frand()-0.5f, ll_frand()-0.5f, 0.f);
+				val.normVec();
+				val.mV[2] = ll_frand()*scaler+1.f-scaler/2.f;
 			}
 
 			LLImageGL::generateTextures(1, &mNoiseMap);
 			
 			gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseMap);
-			LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F_ARB, noiseRes, noiseRes, GL_RGB, GL_FLOAT, noise, false);
+			LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F_ARB, NOISE_MAP_RES, NOISE_MAP_RES, GL_RGB, GL_FLOAT, noise, false);
 			gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
 		}
 
-		if (!mTrueNoiseMap)
-		{
-			const U32 noiseRes = 128;
-			F32 noise[noiseRes*noiseRes*3];
-			for (U32 i = 0; i < noiseRes*noiseRes*3; i++)
-			{
-				noise[i] = ll_frand()*2.0-1.0;
-			}
-
-			LLImageGL::generateTextures(1, &mTrueNoiseMap);
-			gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mTrueNoiseMap);
-			LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F_ARB, noiseRes, noiseRes, GL_RGB,GL_FLOAT, noise, false);
-			gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
-		}
 
 		createLUTBuffers();
 	}
@@ -1328,11 +1298,6 @@ void LLPipeline::createGLBuffers()
 	gBumpImageList.restoreGL();
 }
 
-F32 lerpf(F32 a, F32 b, F32 w)
-{
-	return a + w * (b - a);
-}
-
 void LLPipeline::createLUTBuffers()
 {
 	if (sRenderDeferred)
@@ -5561,13 +5526,6 @@ void LLPipeline::setupAvatarLights(BOOL for_edit)
 		}
 		backlight_diffuse *= backlight_mag / max_component;
 
-		if (LLPipeline::sRenderDeferred)
-		{
-			/*backlight_diffuse.mV[0] = powf(backlight_diffuse.mV[0], 2.2f);
-			backlight_diffuse.mV[1] = powf(backlight_diffuse.mV[1], 2.2f);
-			backlight_diffuse.mV[2] = powf(backlight_diffuse.mV[2], 2.2f);*/
-		}
-
 		mHWLightColors[1] = backlight_diffuse;
 
 		LLLightState* light = gGL.getLight(1);
@@ -7097,22 +7055,20 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 		LLGLEnable test(GL_ALPHA_TEST);
 		
 		gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA);
-
-		LLRenderTarget& target_screen = LLPipeline::sRenderDeferred ? mFinalScreen : mScreen;
 		
-		target_screen.bindTexture(0, 0);
+		LLRenderTarget& render_target = LLPipeline::sRenderDeferred ? mFinalScreen : mScreen;
+		render_target.bindTexture(0, 0);
 		
 		gGL.color4f(1,1,1,1);
 		gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
 
-		drawFullScreenRect(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0);
+		drawFullScreenRect();
 		
-		gGL.getTexUnit(0)->unbind(target_screen.getUsage());
+		gGL.getTexUnit(0)->unbind(render_target.getUsage());
 
 		mGlow[1].flush();
 	}
 
-
 	// power of two between 1 and 1024
 	U32 glowResPow = RenderGlowResolutionPow;
 	const U32 glow_res = llmax(1, 
@@ -7150,7 +7106,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 			gGlowProgram.uniform2f(LLShaderMgr::GLOW_DELTA, 0, delta);
 		}
 
-		drawFullScreenRect(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD1);
+		drawFullScreenRect();
 		
 		mGlow[i%2].flush();
 	}
@@ -7169,7 +7125,6 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 	gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight();
 	glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]);
 
-
 	gGL.flush();
 	
 	LLVertexBuffer::unbind();
@@ -7306,7 +7261,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 				shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF);
 				shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale);
 
-				drawFullScreenRect(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0);
+				drawFullScreenRect();
 
 				unbindDeferredShader(*shader, &mFinalScreen);
 				mDeferredLight.flush();
@@ -7331,7 +7286,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 				shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF);
 				shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale);
 
-				drawFullScreenRect(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0);
+				drawFullScreenRect();
 
 				if (channel > -1)
 				{
@@ -7376,11 +7331,11 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 
 				shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF);
 				shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale);
-				shader->uniform1f(LLShaderMgr::DOF_WIDTH, dof_width-1);
-				shader->uniform1f(LLShaderMgr::DOF_HEIGHT, dof_height-1);
+				shader->uniform1f(LLShaderMgr::DOF_WIDTH, CameraDoFResScale - CameraDoFResScale / dof_width);
+				shader->uniform1f(LLShaderMgr::DOF_HEIGHT, CameraDoFResScale - CameraDoFResScale / dof_height);
 				shader->uniform1f(LLShaderMgr::SECONDS60, fmodf(LLTimer::getElapsedSeconds(), 60.f));
 
-				drawFullScreenRect(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0);
+				drawFullScreenRect();
 
 				if (channel > -1)
 				{
@@ -7418,7 +7373,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 				shader->uniform1f(LLShaderMgr::GLOBAL_GAMMA, 1.0f);
 			}
 
-			drawFullScreenRect(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0);
+			drawFullScreenRect();
 
 			if (channel > -1)
 			{
@@ -7453,7 +7408,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 				gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
 			}
 						
-			drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+			drawFullScreenRect();
 
 			if (channel > -1)
 			{
@@ -7480,14 +7435,11 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 			gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight();
 			glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]);
 
-			F32 scale_x = (F32) width/mFXAABuffer.getWidth();
-			F32 scale_y = (F32) height/mFXAABuffer.getHeight();
-			shader->uniform2f(LLShaderMgr::FXAA_TC_SCALE, scale_x, scale_y);
-			shader->uniform2f(LLShaderMgr::FXAA_RCP_SCREEN_RES, 1.f/width*scale_x, 1.f/height*scale_y);
-			shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT, -0.5f/width*scale_x, -0.5f/height*scale_y, 0.5f/width*scale_x, 0.5f/height*scale_y);
-			shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT2, -2.f/width*scale_x, -2.f/height*scale_y, 2.f/width*scale_x, 2.f/height*scale_y);
+			shader->uniform2f(LLShaderMgr::FXAA_RCP_SCREEN_RES, 1.f/width, 1.f/height);
+			shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT, -0.5f/width, -0.5f/height, 0.5f/width, 0.5f/height);
+			shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT2, -2.f/width, -2.f/height, 2.f/width, 2.f/height);
 			
-			drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+			drawFullScreenRect();
 
 			if (channel > -1)
 			{
@@ -7519,7 +7471,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 		
 		LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0);
 		
-		drawFullScreenRect(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_TEXCOORD1);
+		drawFullScreenRect();
 		
 		if (LLGLSLShader::sNoFixedFunction)
 		{
@@ -7547,25 +7499,18 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 
 		gGL.setColorMask(true, false);
 
-		LLVector2 tc1(0,0);
-		LLVector2 tc2((F32) gViewerWindow->getWorldViewWidthRaw()*2,
-				  (F32) gViewerWindow->getWorldViewHeightRaw()*2);
-
 		LLGLEnable blend(GL_BLEND);
 		gGL.color4f(1,1,1,0.75f);
 
 		gGL.getTexUnit(0)->bind(&mPhysicsDisplay);
 
 		gGL.begin(LLRender::TRIANGLES);
-		gGL.texCoord2f(tc1.mV[0], tc1.mV[1]);
-		gGL.vertex2f(-1,-1);
-		
-		gGL.texCoord2f(tc1.mV[0], tc2.mV[1]);
-		gGL.vertex2f(-1,3);
-		
-		gGL.texCoord2f(tc2.mV[0], tc1.mV[1]);
-		gGL.vertex2f(3,-1);
-		
+		gGL.texCoord2f(0.f, 0.f);
+		gGL.vertex2f(-1.f, -1.f);
+		gGL.texCoord2f(0.f,2.f);
+		gGL.vertex2f(-1.f,  3.f);
+		gGL.texCoord2f(2.f, 0.f);
+		gGL.vertex2f( 3.f, -1.f);
 		gGL.end();
 		gGL.flush();
 
@@ -7652,10 +7597,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* diffus
 		glm::mat4 inv_proj = glm::inverse(glm_get_current_projection());
 		
 		shader.uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, glm::value_ptr(inv_proj));
-		shader.uniform4f(LLShaderMgr::VIEWPORT, (F32) gGLViewport[0],
-									(F32) gGLViewport[1],
-									(F32) gGLViewport[2],
-									(F32) gGLViewport[3]);
 	}
 
 	channel = shader.enableTexture(LLShaderMgr::DEFERRED_NOISE);
@@ -7690,7 +7631,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* diffus
 
 	for (U32 i = 0; i < 4; i++)
 	{
-		channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_TEXTURE);
+		channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i);
 		stop_glerror();
 		if (channel > -1)
 		{
@@ -7774,12 +7715,14 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* diffus
 	LLVector3 ssao_effect = RenderSSAOEffect;
 	shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_EFFECT, ssao_effect[0]);
 
+	shader.uniform2f(LLShaderMgr::DEFERRED_KERN_SCALE, 1.f / mDeferredScreen.getWidth(), 1.f / mDeferredScreen.getHeight());
+	shader.uniform2f(LLShaderMgr::DEFERRED_NOISE_SCALE, mDeferredScreen.getWidth() / NOISE_MAP_RES, mDeferredScreen.getHeight() / NOISE_MAP_RES);
+
 	shader.uniform1f(LLShaderMgr::SECONDS60, (F32) fmod(LLTimer::getElapsedSeconds(), 60.0)); // <alchemy/>
 
 	//F32 shadow_offset_error = 1.f + RenderShadowOffsetError * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2]);
 	F32 shadow_bias_error = RenderShadowBiasError * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2])/3000.f;
 
-	shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredScreen.getWidth(), mDeferredScreen.getHeight());
 	shader.uniform1f(LLShaderMgr::DEFERRED_NEAR_CLIP, LLViewerCamera::getInstance()->getNear()*2.f);
 	shader.uniform1f (LLShaderMgr::DEFERRED_SHADOW_OFFSET, RenderShadowOffset); //*shadow_offset_error);
 	shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_BIAS, RenderShadowBias+shadow_bias_error);
@@ -7798,8 +7741,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* diffus
 		glm::mat4 norm_mat = glm::transpose(glm::inverse(glm_get_current_modelview()));
 		shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, glm::value_ptr(norm_mat));
 	}
-
-	shader.uniform1f(LLShaderMgr::DEFERRED_DOWNSAMPLED_DEPTH_SCALE, llclamp(RenderDeferredSSAOResolutionScale, 0.01f, 1.f));
 }
 
 static LLTrace::BlockTimerStatHandle FTM_GI_TRACE("Trace");
@@ -7852,7 +7793,6 @@ void LLPipeline::renderDeferredLighting()
 		LLGLEnable blend(GL_BLEND);
 
 		const glm::mat4 mat = glm_get_current_modelview();
-
 		{
 			setupHWLights(NULL); //to set mSunDir;
 			glm::vec4 tc(mSunDir[0], mSunDir[1], mSunDir[2], 0.f);
@@ -7878,10 +7818,9 @@ void LLPipeline::renderDeferredLighting()
 				mDeferredDownsampledDepth.bindTarget();
 				mDeferredDownsampledDepth.clear(GL_DEPTH_BUFFER_BIT);
 				bindDeferredShader(gDeferredDownsampleDepthNearestProgram);
-				gDeferredDownsampleDepthNearestProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredDownsampledDepth.getWidth()/ssao_scale, mDeferredDownsampledDepth.getHeight()/ssao_scale);
 				{
 					LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS);
-					drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+					drawFullScreenRect();
 				}
 				mDeferredDownsampledDepth.flush();
 				unbindDeferredShader(gDeferredDownsampleDepthNearestProgram);
@@ -7897,11 +7836,10 @@ void LLPipeline::renderDeferredLighting()
 				if(ssao_scale < 1.f)
 				{
 					glViewport(0,0,mDeferredDownsampledDepth.getWidth(),mDeferredDownsampledDepth.getHeight());
-					gDeferredSSAOProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredDownsampledDepth.getWidth()/ssao_scale, mDeferredDownsampledDepth.getHeight()/ssao_scale);
 				}
 				{
 					LLGLDepthTest depth(GL_FALSE);
-					drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+					drawFullScreenRect();
 				}
 				mScreen.flush();
 				unbindDeferredShader(gDeferredSSAOProgram);
@@ -7918,7 +7856,8 @@ void LLPipeline::renderDeferredLighting()
 				mDeferredLight.clear(GL_COLOR_BUFFER_BIT);
 				glClearColor(0,0,0,0);
 
-				gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredLight.getWidth(), mDeferredLight.getHeight());
+				F32 ssao_scale = llclamp(RenderDeferredSSAOResolutionScale, .01f, 1.f);
+				gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_KERN_SCALE, ssao_scale, ssao_scale);
 
 				//Enable bilinear filtering, as the screen tex resolution may not match current framebuffer resolution. Eg, half-res SSAO
 				// diffuse map should only be found if the sun shader is the SSAO variant.
@@ -7932,7 +7871,7 @@ void LLPipeline::renderDeferredLighting()
 				{
 					LLGLDisable blend(GL_BLEND);
 					LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
-					drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+					drawFullScreenRect();
 				}
 
 				if (channel > -1)
@@ -7960,28 +7899,13 @@ void LLPipeline::renderDeferredLighting()
 			F32 blur_size = RenderShadowBlurSize;
 			F32 dist_factor = RenderShadowBlurDistFactor;
 
-			// sample symmetrically with the middle sample falling exactly on 0.0
-			F32 x = 0.f;
-
-			LLVector3 gauss[32]; // xweight, yweight, offset
-
-			for (U32 i = 0; i < kern_length; i++)
-			{
-				gauss[i].mV[0] = llgaussian(x, go.mV[0]);
-				gauss[i].mV[1] = llgaussian(x, go.mV[1]);
-				gauss[i].mV[2] = x;
-				x += 1.f;
-			}
-
-			gDeferredBlurLightProgram.uniform2f(sDelta, 1.f, 0.f);
+			gDeferredBlurLightProgram.uniform2f(sDelta, (blur_size * (kern_length / 2.f - 0.5f)) / mScreen.getWidth(), 0.f);
 			gDeferredBlurLightProgram.uniform1f(sDistFactor, dist_factor);
-			gDeferredBlurLightProgram.uniform3fv(sKern, kern_length, gauss[0].mV);
-			gDeferredBlurLightProgram.uniform1f(sKernScale, blur_size * (kern_length/2.f - 0.5f));
 		
 			{
 				LLGLDisable blend(GL_BLEND);
 				LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
-				drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+				drawFullScreenRect();
 			}
 			
 			mScreen.flush();
@@ -7990,12 +7914,12 @@ void LLPipeline::renderDeferredLighting()
 			bindDeferredShader(gDeferredBlurLightProgram, &mScreen, &mScreen);
 			mDeferredLight.bindTarget();
 
-			gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f);
+			gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, (blur_size * (kern_length / 2.f - 0.5f)) / mScreen.getHeight());
 
 			{
 				LLGLDisable blend(GL_BLEND);
 				LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
-				drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+				drawFullScreenRect();
 			}
 			mDeferredLight.flush();
 			unbindDeferredShader(gDeferredBlurLightProgram, &mScreen, &mScreen);
@@ -8030,7 +7954,7 @@ void LLPipeline::renderDeferredLighting()
 				gGL.pushMatrix();
 				gGL.loadIdentity();
 
-				drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+				drawFullScreenRect();
 
 				gGL.popMatrix();
 				gGL.matrixMode(LLRender::MM_MODELVIEW);
@@ -8274,7 +8198,7 @@ void LLPipeline::renderDeferredLighting()
 						gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z);
 						far_z = 0.f;
 						count = 0; 
-						drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+						drawFullScreenRect();
 						unbindDeferredShader(gDeferredMultiLightProgram[idx]);
 					}
 				}
@@ -8312,7 +8236,7 @@ void LLPipeline::renderDeferredLighting()
 					gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s);
 					gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV);
 					gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f);
-					drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+					drawFullScreenRect();
 				}
 
 				gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION);
@@ -8351,9 +8275,7 @@ void LLPipeline::renderDeferredLighting()
 			gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
 		}
 		
-		gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mScreen.getWidth(), mScreen.getHeight());
-		
-		drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+		drawFullScreenRect();
 		
 		gGL.getTexUnit(channel)->unbind(mScreen.getUsage());
 		gDeferredPostGammaCorrectProgram.unbind();
@@ -8483,10 +8405,9 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
 				mDeferredDownsampledDepth.bindTarget();
 				mDeferredDownsampledDepth.clear(GL_DEPTH_BUFFER_BIT);
 				bindDeferredShader(gDeferredDownsampleDepthNearestProgram);
-				gDeferredDownsampleDepthNearestProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredDownsampledDepth.getWidth()/ssao_scale, mDeferredDownsampledDepth.getHeight()/ssao_scale);
 				{
 					LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS);
-					drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+					drawFullScreenRect();
 				}
 				mDeferredDownsampledDepth.flush();
 				unbindDeferredShader(gDeferredDownsampleDepthNearestProgram);
@@ -8502,11 +8423,10 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
 				if(ssao_scale < 1.f)
 				{
 					glViewport(0,0,mDeferredDownsampledDepth.getWidth(),mDeferredDownsampledDepth.getHeight());
-					gDeferredSSAOProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredDownsampledDepth.getWidth()/ssao_scale, mDeferredDownsampledDepth.getHeight()/ssao_scale);	
 				}
 				{
 					LLGLDepthTest depth(GL_FALSE);
-					drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+					drawFullScreenRect();
 				}
 				mScreen.flush();
 				unbindDeferredShader(gDeferredSSAOProgram);
@@ -8519,12 +8439,14 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
 			{ //paint shadow/SSAO light map (direct lighting lightmap)
 				LL_RECORD_BLOCK_TIME(FTM_SUN_SHADOW);
 				bindDeferredShader(gDeferredSunProgram);
+
+				F32 ssao_scale = llclamp(RenderDeferredSSAOResolutionScale, .01f, 1.f);
+				gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_KERN_SCALE, ssao_scale, ssao_scale);
+
 				glClearColor(1,1,1,1);
 				mDeferredLight.clear(GL_COLOR_BUFFER_BIT);
 				glClearColor(0,0,0,0);
 
-				gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredLight.getWidth(), mDeferredLight.getHeight());
-				
 				//Enable bilinear filtering, as the screen tex resolution may not match current framebuffer resolution. Eg, half-res SSAO
 				// diffuse map should only be found if the sun shader is the SSAO variant.
 				S32 channel = gDeferredSunProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage());
@@ -8537,7 +8459,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
 				{
 					LLGLDisable blend(GL_BLEND);
 					LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS);
-					drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+					drawFullScreenRect();
 				}
 
 				if (channel > -1)
@@ -8580,7 +8502,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
 				gGL.pushMatrix();
 				gGL.loadIdentity();
 
-				drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+				drawFullScreenRect();
 
 				gGL.popMatrix();
 				gGL.matrixMode(LLRender::MM_MODELVIEW);
@@ -8818,7 +8740,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
 						gDeferredMultiLightProgram[idx].uniform1f(LLShaderMgr::MULTI_LIGHT_FAR_Z, far_z);
 						far_z = 0.f;
 						count = 0; 
-						drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+						drawFullScreenRect();
 					}
 				}
 				
@@ -8857,7 +8779,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
 					gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s);
 					gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV);
 					gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_FALLOFF, volume->getLightFalloff()*0.5f);
-					drawFullScreenRect(LLVertexBuffer::MAP_VERTEX);
+					drawFullScreenRect();
 				}
 
 				gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION);
@@ -8900,8 +8822,6 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
 			gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
 		}
 		
-		gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, target->getWidth(), target->getHeight());
-		
 		F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma");
 
 		gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f));
@@ -10002,9 +9922,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 	//far clip on last split is minimum of camera view distance and 128
 	mSunClipPlanes = LLVector4(clip, clip.mV[2] * clip.mV[2]/clip.mV[1]);
 
-	clip = RenderShadowOrthoClipPlanes;
-	mSunOrthoClipPlanes = LLVector4(clip, clip.mV[2]*clip.mV[2]/clip.mV[1]);
-
 	//currently used for amount to extrude frusta corners for constructing shadow frusta
 	//LLVector3 n = RenderShadowNearDist;
 	//F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] };
@@ -11331,31 +11248,21 @@ void LLPipeline::restoreHiddenObject( const LLUUID& id )
 	}
 }
 
-void LLPipeline::drawFullScreenRect(U32 data_mask)
+void LLPipeline::drawFullScreenRect()
 {
 	if(mAuxScreenRectVB.isNull())
 	{
 		mAuxScreenRectVB = new LLVertexBuffer(AUX_VB_MASK, 0);
 		mAuxScreenRectVB->allocateBuffer(3, 0, true);
 		LLStrider<LLVector3> vert;
-		LLStrider<LLVector2> tc0, tc1;
 		mAuxScreenRectVB->getVertexStrider(vert);
-		mAuxScreenRectVB->getTexCoord0Strider(tc0);
-		mAuxScreenRectVB->getTexCoord1Strider(tc1);
 
 		vert[0].set(-1.f,-1.f,0.f);
 		vert[1].set(3.f,-1.f,0.f);
 		vert[2].set(-1.f,3.f,0.f);
 
-		tc0[0].set(0.f, 0.f);
-		tc0[1].set(mScreen.getWidth()*2.f, 0.f);
-		tc0[2].set(0.f, mScreen.getHeight()*2.f);
-
-		tc1[0].set(0.f, 0.f);
-		tc1[1].set(2.f, 0.f);
-		tc1[2].set(0.f, 2.f);
 	}
-	mAuxScreenRectVB->setBuffer(data_mask);
+	mAuxScreenRectVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
 	mAuxScreenRectVB->drawArrays(LLRender::TRIANGLES, 0, 3);
 }
 
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 20f270425f..e7bfdae2e4 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -418,7 +418,7 @@ private:
 	void hideDrawable( LLDrawable *pDrawable );
 	void unhideDrawable( LLDrawable *pDrawable );
 
-	void drawFullScreenRect(U32 data_mask);
+	void drawFullScreenRect();
 public:
 	enum {GPU_CLASS_MAX = 3 };
 
@@ -622,7 +622,6 @@ public:
 	LLVector4				mSunClipPlanes;
 	LLVector4				mSunOrthoClipPlanes;
 
-	LLVector2				mScreenScale;
 
 	//water reflection texture
 	LLRenderTarget				mWaterRef;
@@ -635,7 +634,6 @@ public:
 
 	//noise map
 	U32					mNoiseMap;
-	U32					mTrueNoiseMap;
 	U32					mLightFunc;
 
 	LLColor4				mSunDiffuse;
-- 
GitLab