diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 61648e527da70b0ccdc08ec88fc3bfc9d3abf432..95ce2271710de803e93f08e2e690c623572bfbeb 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -76,6 +76,10 @@ hasAlphaMask(false)
 LLGLSLShader::LLGLSLShader()
 	: mProgramObject(0), mActiveTextureChannels(0), mShaderLevel(0), mShaderGroup(SG_DEFAULT), mUniformsDirty(FALSE)
 {
+	for (U32 i = 0; i < LLRender::NUM_MATRIX_MODES; ++i)
+	{
+		mMatHash[i] = 0xFFFFFFFF;
+	}
 }
 
 void LLGLSLShader::unload()
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index 558ea66b50f7bd10d6c74377914e893ec62412b2..c1765e2701af541d531d8d69b1a271ca415801c2 100644
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -117,7 +117,6 @@ class LLGLSLShader
 	GLint getAttribLocation(U32 attrib);
 	GLint mapUniformTextureChannel(GLint location, GLenum type);
 	
-
 	//enable/disable texture channel for specified uniform
 	//if given texture uniform is active in the shader, 
 	//the corresponding channel will be active upon return
@@ -132,6 +131,8 @@ class LLGLSLShader
 	// Unbinds any previously bound shader by explicitly binding no shader.
 	static void bindNoShader(void);
 
+	U32 mMatHash[LLRender::NUM_MATRIX_MODES];
+
 	GLhandleARB mProgramObject;
 	std::vector<GLint> mAttribute; //lookup table of attribute enum to attribute channel
 	std::vector<GLint> mUniform;   //lookup table of uniform enum to uniform location
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 27d25c0d3a63bc7981ae5384b7351c3121a9c201..359e6fd5609a8015bf6fb5692167ab28a4a2b3de 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -1018,6 +1018,8 @@ void LLRender::refreshState(void)
 
 void LLRender::syncMatrices()
 {
+	stop_glerror();
+
 	GLenum mode[] = 
 	{
 		GL_MODELVIEW,
@@ -1028,27 +1030,105 @@ void LLRender::syncMatrices()
 		GL_TEXTURE,
 	};
 
-	for (U32 i = 0; i < 2; ++i)
+	std::string name[] = 
+	{
+		"modelview_matrix",
+		"projection_matrix",
+		"texture_matrix0",
+		"texture_matrix1",
+		"texture_matrix2",
+		"texture_matrix3",
+	};
+
+	LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
+
+	if (shader)
 	{
-		if (mMatHash[i] != mCurMatHash[i])
+		
+		llassert(shader);
+
+		bool do_normal = false;
+		bool do_mvp = false;
+
+		for (U32 i = 0; i < NUM_MATRIX_MODES; ++i)
 		{
-			glMatrixMode(mode[i]);
-			glLoadMatrixf(mMatrix[i][mMatIdx[i]].m);
-			mCurMatHash[i] = mMatHash[i];
+			if (mMatHash[i] != shader->mMatHash[i])
+			{
+				shader->uniformMatrix4fv(name[i], 1, GL_FALSE, mMatrix[i][mMatIdx[i]].m);
+				shader->mMatHash[i] = mMatHash[i];
+
+				if (i == MM_MODELVIEW)
+				{
+					do_normal = true;
+					do_mvp = true;
+				}
+				else if (i == MM_PROJECTION)
+				{
+					do_mvp = true;
+				}
+			}
 		}
-	}
 
-	for (U32 i = 2; i < NUM_MATRIX_MODES; ++i)
+		if (do_normal)
+		{
+			S32 loc = shader->getUniformLocation("normal_matrix");
+			if (loc > -1)
+			{
+				U32 i = MM_MODELVIEW;
+
+				glh::matrix4f norm = mMatrix[i][mMatIdx[i]].inverse().transpose();
+
+				F32 norm_mat[] = 
+				{
+					norm.m[0], norm.m[1], norm.m[2],
+					norm.m[4], norm.m[5], norm.m[6],
+					norm.m[8], norm.m[9], norm.m[10] 
+				};
+
+				shader->uniformMatrix3fv("normal_matrix", 1, GL_FALSE, norm_mat);
+			}
+		}
+
+		if (do_mvp)
+		{
+			S32 loc = shader->getUniformLocation("modelview_projection_matrix");
+			if (loc > -1)
+			{
+				U32 mv = MM_MODELVIEW;
+				U32 proj = MM_PROJECTION;
+
+				glh::matrix4f mvp = mMatrix[mv][mMatIdx[mv]];
+				mvp.mult_left(mMatrix[proj][mMatIdx[proj]]);
+				
+				shader->uniformMatrix4fv("modelview_projection_matrix", 1, GL_FALSE, mvp.m);
+			}
+		}
+	}
+	else
 	{
-		if (mMatHash[i] != mCurMatHash[i])
+		for (U32 i = 0; i < 2; ++i)
 		{
-			gGL.getTexUnit(i-2)->activate();
-			glMatrixMode(mode[i]);
-			glLoadMatrixf(mMatrix[i][mMatIdx[i]].m);
-			mCurMatHash[i] = mMatHash[i];
+			if (mMatHash[i] != mCurMatHash[i])
+			{
+				glMatrixMode(mode[i]);
+				glLoadMatrixf(mMatrix[i][mMatIdx[i]].m);
+				mCurMatHash[i] = mMatHash[i];
+			}
+		}
+
+		for (U32 i = 2; i < NUM_MATRIX_MODES; ++i)
+		{
+			if (mMatHash[i] != mCurMatHash[i])
+			{
+				gGL.getTexUnit(i-2)->activate();
+				glMatrixMode(mode[i]);
+				glLoadMatrixf(mMatrix[i][mMatIdx[i]].m);
+				mCurMatHash[i] = mMatHash[i];
+			}
 		}
 	}
-	
+
+	stop_glerror();
 }
 
 void LLRender::translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z)
diff --git a/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl b/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl
index ec1a81379079762300ff400f5a580dcb199c2646..c98b99b15acf089797c9c5cdf3c055be7dfbd512 100644
--- a/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl
+++ b/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 projection_matrix;
+
 attribute vec3 position;
 attribute vec3 normal;
 attribute vec2 texcoord0;
@@ -51,9 +53,7 @@ void main()
 	norm.z = dot(trans[2].xyz, normal);
 	norm = normalize(norm);
 		
-	gl_Position = gl_ProjectionMatrix * pos;
-	
-	//gl_Position = gl_ModelViewProjectionMatrix * position;
+	gl_Position = projection_matrix * pos;
 	
 	gl_FogFragCoord = length(pos.xyz);
 
diff --git a/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl b/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl
index 31db10ae855166e3938070f685fe76946f0e3372..9a19fb928bd7f4ded9320c0d1b7f34e7e26fe567 100644
--- a/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl
+++ b/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl
@@ -22,7 +22,11 @@
  * 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;
@@ -35,12 +39,12 @@ void calcAtmospherics(vec3 inPositionEye);
 void main()
 {
 	//transform vertex
-	vec3 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0)).xyz;
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	vec3 pos = (modelview_matrix * vec4(position.xyz, 1.0)).xyz;
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
 	
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec3 norm = normalize(normal_matrix * normal);
 		
 	calcAtmospherics(pos.xyz);
 
diff --git a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl
index f07e5c124b16e5a7e1796c98f7358c215ba8afd1..21a9e91bf518c96079468eb533b0ecf969a6d2e1 100644
--- a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl
+++ b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 projection_matrix;
+
 attribute vec3 position;
 attribute vec4 diffuse_color;
 attribute vec2 texcoord0;
@@ -41,5 +43,5 @@ void main()
 			
 	gl_FrontColor = diffuse_color;
 	gl_TexCoord[0] = vec4(texcoord0,0,1);
-	gl_Position = gl_ProjectionMatrix * pos;
+	gl_Position = projection_matrix * pos;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
index 2c2b58d59b3a5f041a24afae90449a8f08f1cea1..9deb9a701e6a02f5c0a8aab817e84f2f9ea6ce0c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
@@ -21,7 +21,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 projection_matrix;
+uniform mat4 modelview_matrix;
 
 attribute vec3 position;
 attribute vec3 normal;
@@ -86,14 +88,14 @@ void main()
 	vec3 norm;
 	
 	mat4 trans = getObjectSkinnedTransform();
-	trans = gl_ModelViewMatrix * trans;
+	trans = modelview_matrix * trans;
 	
 	pos = trans * vec4(position.xyz, 1.0);
 	
 	norm = position.xyz + normal.xyz;
-	norm = normalize(( trans*vec4(norm, 1.0) ).xyz-pos.xyz);
+	norm = normalize(( trans*vec4(norojrm, 1.0) ).xyz-pos.xyz);
 	
-	vec4 frag_pos = gl_ProjectionMatrix * pos;
+	vec4 frag_pos = projection_matrix * pos;
 	gl_Position = frag_pos;
 	
 	vary_position = pos.xyz;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 7a2f34ca1dfc2c67a46d22d7ad1fbe1d66d71b88..51e7c0780de7d4f5666b2b2189b7aab0c8bcd1df 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -23,6 +23,11 @@
  * $/LicenseInfo$
  */
 
+uniform mat3 normal_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
+
 attribute vec4 position;
 attribute vec3 normal;
 attribute vec4 diffuse_color;
@@ -85,12 +90,12 @@ void main()
 	//transform vertex
 	vec4 vert = vec4(position.xyz, 1.0);
 	vary_texture_index = position.w;
-	vec4 pos = (gl_ModelViewMatrix * vert);
-	gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
+	vec4 pos = (modelview_matrix * vert);
+	gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
 	
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec3 norm = normalize(normal_matrix * normal);
 	
 	float dp_directional_light = max(0.0, dot(norm, gl_LightSource[0].position.xyz));
 	vary_position = pos.xyz + gl_LightSource[0].position.xyz * (1.0-dp_directional_light)*shadow_offset;
@@ -126,7 +131,7 @@ void main()
 
 	gl_FogFragCoord = pos.z;
 	
-	pos = gl_ModelViewProjectionMatrix * vert;
+	pos = modelview_projection_matrix * vert;
 	vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
 	
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl
index e03615eebbd65a08c7ad88eb9a327a08f6c6513a..fc055e555d2aaaee2cd33e2c6445d6e298066623 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl
@@ -22,6 +22,10 @@
  * $/LicenseInfo$
  */
 
+uniform mat4 projection_matrix;
+uniform mat4 modelview_matrix;
+uniform mat4 texture_matrix0;
+
 attribute vec3 position;
 attribute vec4 diffuse_color;
 attribute vec2 texcoord0;
@@ -31,16 +35,16 @@ mat4 getObjectSkinnedTransform();
 void main()
 {
 	//transform vertex
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
 	mat4 mat = getObjectSkinnedTransform();
 	
-	mat = gl_ModelViewMatrix * mat;
+	mat = modelview_matrix * mat;
 	vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
 	
 	gl_FrontColor = diffuse_color;
 	
-	vec4 p = gl_ProjectionMatrix * vec4(pos, 1.0);
+	vec4 p = projection_matrix * vec4(pos, 1.0);
 	p.z = max(p.z, -p.w+0.01);
 	gl_Position = p;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
index e15727f6f7b04f091917add42e43b0c4a84f1a66..df4de4f4329d3657ac160eaef1c7c8b6e8842abd 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 projection_matrix;
+
 attribute vec3 position;
 attribute vec3 normal;
 attribute vec2 texcoord0;
@@ -96,7 +98,7 @@ void main()
 	norm.z = dot(trans[2].xyz, normal);
 	norm = normalize(norm);
 		
-	vec4 frag_pos = gl_ProjectionMatrix * pos;
+	vec4 frag_pos = projection_matrix * pos;
 	gl_Position = frag_pos;
 	
 	vary_position = pos.xyz;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarEyesV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarEyesV.glsl
index 58efa47567187707f2c98449bcadb14ce354ea5c..d5c20a22d93c7f115b1401d9b5e9799541e7e35a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarEyesV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarEyesV.glsl
@@ -22,7 +22,10 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat3 normal_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 attribute vec3 normal;
@@ -34,10 +37,10 @@ varying vec3 vary_normal;
 void main()
 {
 	//transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0); 
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); 
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
-	vary_normal = normalize(gl_NormalMatrix * normal);
+	vary_normal = normalize(normal_matrix * normal);
 
 	gl_FrontColor = diffuse_color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl
index 543e998def75d8adffd5985dd4249d6a2c0df04a..6835b9c021406fc5ffca9039676950eef0d5ba75 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl
@@ -23,7 +23,7 @@
  * $/LicenseInfo$
  */
  
-
+uniform mat4 projection_matrix;
 
 mat4 getSkinnedTransform();
 
@@ -52,7 +52,7 @@ void main()
 	norm.z = dot(trans[2].xyz, normal);
 	norm = normalize(norm);
 	
-	pos = gl_ProjectionMatrix * pos;
+	pos = projection_matrix * pos;
 	post_pos = pos;
 
 	gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl
index 66e9119e28e3f6e53a5d9f4e77af236ccca27c8c..704845d310a46fae2a6b756a6505ff23f495f748 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl
@@ -23,6 +23,8 @@
  * $/LicenseInfo$
  */
  
+uniform mat4 projection_matrix;
+
 attribute vec3 position;
 attribute vec3 normal;
 attribute vec2 texcoord0;
@@ -54,7 +56,7 @@ void main()
 	
 	vary_normal = norm;
 	
-	gl_Position = gl_ProjectionMatrix * pos;
+	gl_Position = projection_matrix * pos;
 }
 
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl
index 0168c40ae53f77a815f9eb94843e6359dfffd65d..5339e380181d6fa61dfa4831b8801d3adbe32974 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 
 varying vec2 vary_fragcoord;
@@ -31,7 +33,7 @@ uniform vec2 screen_res;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/bumpSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl
index 421299d4a78a1988a4502eb4c5a8e26557aa04ee..cf93430217e75052a7c3e195dd6341a0f960bbe1 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl
@@ -22,6 +22,10 @@
  * $/LicenseInfo$
  */
 
+uniform mat4 projection_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_matrix;
+
 attribute vec3 position;
 attribute vec4 diffuse_color;
 attribute vec3 normal;
@@ -36,11 +40,11 @@ mat4 getObjectSkinnedTransform();
 
 void main()
 {
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
 	mat4 mat = getObjectSkinnedTransform();
 	
-	mat = gl_ModelViewMatrix * mat;
+	mat = modelview_matrix * mat;
 	
 	vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
 	
@@ -53,6 +57,6 @@ void main()
 	vary_mat1 = vec3(t.y, b.y, n.y);
 	vary_mat2 = vec3(t.z, b.z, n.z);
 	
-	gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
+	gl_Position = projection_matrix*vec4(pos, 1.0);
 	gl_FrontColor = diffuse_color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl
index b724def93de770e61ebaf5e5629d4f7ad55ec869..9ec31383acf43c0cba3bac7eee69b902a3df24eb 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl
@@ -22,7 +22,11 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat3 normal_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec4 diffuse_color;
 attribute vec3 normal;
@@ -36,11 +40,11 @@ varying vec3 vary_mat2;
 void main()
 {
 	//transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0); 
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); 
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
-	vec3 n = normalize(gl_NormalMatrix * normal);
-	vec3 b = normalize(gl_NormalMatrix * binormal);
+	vec3 n = normalize(normal_matrix * normal);
+	vec3 b = normalize(normal_matrix * binormal);
 	vec3 t = cross(b, n);
 	
 	vary_mat0 = vec3(t.x, b.x, n.x);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
index 297b3904a60c70459823d38e3f4a21cc25c33669..67b5e7fb837e53863eef321efe1e17a65b1e9fa2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec2 texcoord0;
 
@@ -60,7 +62,7 @@ void main()
 {
 
 	// World / view / projection
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 
 	gl_TexCoord[0] = vec4(texcoord0,0,1);
 
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseNoColorV.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseNoColorV.glsl
index ff9578e2533cf9feef0af64a1eb916e7bbf3556d..37864578ecdf4e78275b942f2a9e9955b1085024 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseNoColorV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseNoColorV.glsl
@@ -1,10 +1,31 @@
 /** 
  * @file diffuseNoColorV.glsl
  *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+  * $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_projection_matrix; 
 
 attribute vec3 position;
 attribute vec3 normal;
@@ -16,8 +37,8 @@ varying float vary_texture_index;
 void main()
 {
 	//transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0); 
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); 
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
-	vary_normal = normalize(gl_NormalMatrix * normal);
+	vary_normal = normalize(normal_matrix * normal);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl
index 02fb34af32640aea686d9a0e5955bc4c428c15a4..880a7ea0a2967f41c09c4a023f1caab7f4e9812c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl
@@ -22,7 +22,9 @@
  * $/LicenseInfo$
  */
 
-
+uniform mat4 projection_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_matrix;
 
 attribute vec3 position;
 attribute vec4 diffuse_color;
@@ -35,11 +37,11 @@ mat4 getObjectSkinnedTransform();
 
 void main()
 {
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
 	mat4 mat = getObjectSkinnedTransform();
 	
-	mat = gl_ModelViewMatrix * mat;
+	mat = modelview_matrix * mat;
 	vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
 	
 	vec4 norm = vec4(position.xyz, 1.0);
@@ -51,5 +53,5 @@ void main()
 			
 	gl_FrontColor = diffuse_color;
 	
-	gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
+	gl_Position = projection_matrix*vec4(pos, 1.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
index 553cfff52f293fe2cb617298b4e7da5272fcc7bc..e158df13f70e667532dde16f99c102de8f7290e8 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
@@ -22,7 +22,10 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat3 normal_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_projection_matrix;
 
 attribute vec4 position;
 attribute vec4 diffuse_color;
@@ -35,11 +38,11 @@ varying float vary_texture_index;
 void main()
 {
 	//transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0); 
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); 
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
 	vary_texture_index = position.w;
-	vary_normal = normalize(gl_NormalMatrix * normal);
+	vary_normal = normalize(normal_matrix * normal);
 
 	gl_FrontColor = diffuse_color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/emissiveV.glsl b/indra/newview/app_settings/shaders/class1/deferred/emissiveV.glsl
index 9841943fe69238e477d12b0051a544ca429c4420..fccf8554d21297c3698b44eb484219d9d36e10fa 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/emissiveV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/emissiveV.glsl
@@ -1,10 +1,31 @@
 /** 
  * @file emissiveV.glsl
  *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+  * $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 texture_matrix0;
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
 
 attribute vec4 position;
 attribute float emissive;
@@ -23,12 +44,12 @@ void main()
 {
 	//transform vertex
 	vec4 vert = vec4(position.xyz, 1.0);
-	vec4 pos = (gl_ModelViewMatrix * vert);
+	vec4 pos = (modelview_matrix * vert);
 	vary_texture_index = position.w;
 
-	gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
 	
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
 	calcAtmospherics(pos.xyz);
 	
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl
index 93571058dce37a6bf07e10602b013b0aceedc9af..27591654719ab755e9033168d189446b2668b473 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl
@@ -22,7 +22,11 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
+
 
 attribute vec4 position;
 attribute vec4 diffuse_color;
@@ -41,12 +45,12 @@ void main()
 {
 	//transform vertex
 	vec4 vert = vec4(position.xyz, 1.0);
-	vec4 pos = (gl_ModelViewMatrix * vert);
+	vec4 pos = (modelview_matrix * vert);
 	vary_texture_index = position.w;
 
-	gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
 	
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
 	calcAtmospherics(pos.xyz);
 	
diff --git a/indra/newview/app_settings/shaders/class1/deferred/giV.glsl b/indra/newview/app_settings/shaders/class1/deferred/giV.glsl
index 1a23be349eea05fd3e1b8e0d198a329055d2b595..2766691bd02b29eb3b0cbc9f599dc6cc82eaa2a2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/giV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/giV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec4 diffuse_color;
 attribute vec2 texcoord0;
@@ -35,7 +37,7 @@ uniform vec2 screen_res;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/impostorV.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl
index 28ba2c432da3117c21135b670afd5a497a8fc1cb..645b0d793a7e87fe71602ad3ee70efbbb9262600 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl
@@ -22,7 +22,10 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec4 diffuse_color;
 attribute vec2 texcoord0;
@@ -30,8 +33,8 @@ attribute vec2 texcoord0;
 void main()
 {
 	//transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0); 
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); 
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
 	gl_FrontColor = diffuse_color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl
index 3f2e07cf0875886fd310006fcb92be14acc33f84..dafc55a6ff57ea3b1009fb292b8c31f82a953a2b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl
@@ -23,6 +23,7 @@
  * $/LicenseInfo$
  */
 
+uniform mat4 modelview_projection_matrix;
  
 attribute vec3 position;
 attribute vec4 diffuse_color;
@@ -34,7 +35,7 @@ uniform vec2 screen_res;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/multiPointLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl
index 39e60b6cc8d21ac1ceae688b1baec6f1fa0fa2a0..1d54d7bede048a0323865422eba829dbe0096809 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl
@@ -23,6 +23,7 @@
  * $/LicenseInfo$
  */
 
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 
@@ -31,7 +32,7 @@ varying vec4 vary_fragcoord;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
 	vary_fragcoord = pos;
 
 	gl_Position = pos;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
index afaf58020bcc9dcdee30305dd0f4693be59317bf..cab98175834af0d6a925bea45d3705bdbb7e5183 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
@@ -23,6 +23,8 @@
  * $/LicenseInfo$
  */
 
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 
 varying vec4 vary_fragcoord;
@@ -30,7 +32,7 @@ varying vec4 vary_fragcoord;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
 	vary_fragcoord = pos;
 		
 	gl_Position = pos;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl
index 74a9df64e0bba786c44c0db883ed912a10310c81..b11f26fbae31de9ca9ca744e790b8db146b93dda 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 
 varying vec2 vary_fragcoord;
@@ -35,7 +37,7 @@ uniform vec2 screen_res;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/postgiV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl
index a3751be1fbf67e9a1540fca17a220f7860a4b421..61c639364826ab332c042ee1fc7b84bea0b4fc0c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl
@@ -22,6 +22,8 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
+
+uniform mat4 modelview_projection_matrix;
  
 attribute vec3 position;
 
@@ -32,7 +34,7 @@ uniform vec2 screen_res;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/shadowAlphaMaskV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl
index bbd7516337a688e5b2ac54f1f1e6de839b45a56e..f7bed00214d07c1dbd2e7d6492f1d45c1adf8018 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl
@@ -22,7 +22,10 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec4 diffuse_color;
 attribute vec2 texcoord0;
@@ -32,12 +35,12 @@ varying vec4 post_pos;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
+	vec4 pos = modelview_projection_matrix*vec4(position.xyz, 1.0);
 	
 	post_pos = pos;
 	
 	gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w);
 	
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	gl_FrontColor = diffuse_color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl
index 1ac3dbd5dea37fe523ee1456fab8a22b37aa3932..190cac9e2ceaa4f9857fe3ded37903cd09be3f98 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 
 varying vec4 post_pos;
@@ -30,7 +32,7 @@ varying vec4 post_pos;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
+	vec4 pos = modelview_projection_matrix*vec4(position.xyz, 1.0);
 	
 	post_pos = pos;
 	
diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
index 23171fe940b48c34810172f3958590c18d6f3bbe..e97d3e082879ee39e3c575e6edaffc50079e6648 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec2 texcoord0;
 
@@ -58,7 +60,7 @@ void main()
 {
 
 	// World / view / projection
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 	gl_TexCoord[0] = vec4(texcoord0,0,1);
 
 	// Get relative position
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
index 4b6b3c242ea1bdf09e14b14554bd18579be26b21..7d1e99b4aaf954579193279c69bda11f9502abb5 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
@@ -23,6 +23,7 @@
  * $/LicenseInfo$
  */
  
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 
@@ -32,7 +33,7 @@ varying vec2 vary_fragcoord;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/starsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl
index dbd2b5595a357f7f7abae895e34894bfa7a452d2..1fcb05ef2c8383f527907a8d844b820eeff7bedd 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 attribute vec4 diffuse_color;
@@ -31,7 +33,7 @@ attribute vec2 texcoord0;
 void main()
 {
 	//transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0); 
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); 
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	gl_FrontColor = diffuse_color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl
index d19e67b67de3786ff4ba2547dfc2181f6339deec..10751304ae2eb1986a173cb82a3dfa5ec0102a89 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl
@@ -22,6 +22,8 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
+
+uniform mat4 modelview_projection_matrix;
  
 attribute vec3 position;
 
@@ -32,7 +34,7 @@ uniform vec2 screen_res;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/terrainV.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl
index 793106f2cf2182ecc0b3ee3d20f13a8d190004db..7f84ef1cff3d52d18de4442ccdd06d82368c406a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl
@@ -22,7 +22,11 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat3 normal_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec3 normal;
 attribute vec4 diffuse_color;
@@ -48,12 +52,12 @@ vec4 texgen_object(vec4  vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
 void main()
 {
 	//transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 			
-	vary_normal = normalize(gl_NormalMatrix * normal);
+	vary_normal = normalize(normal_matrix * normal);
 	
 	// Transform and pass tex coords
- 	gl_TexCoord[0].xy = texgen_object(vec4(position, 1.0), vec4(texcoord0,0,1), gl_TextureMatrix[0], gl_ObjectPlaneS[0], gl_ObjectPlaneT[0]).xy;
+ 	gl_TexCoord[0].xy = texgen_object(vec4(position, 1.0), vec4(texcoord0,0,1), texture_matrix0, gl_ObjectPlaneS[0], gl_ObjectPlaneT[0]).xy;
 	
 	vec4 t = vec4(texcoord1,0,1);
 	
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeShadowV.glsl
index 42ce2f522671a8d90a4abbad3e4b2e34356d1277..c695d374ac980694fef2d03647773b260eb1ecd0 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/treeShadowV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeShadowV.glsl
@@ -1,9 +1,30 @@
 /** 
  * @file treeShadowV.glsl
  *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+  * $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 texture_matrix0;
+uniform mat4 modelview_projection_matrix;
  
 attribute vec3 position;
 attribute vec2 texcoord0;
@@ -13,11 +34,11 @@ varying vec4 post_pos;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
+	vec4 pos = modelview_projection_matrix*vec4(position.xyz, 1.0);
 	
 	post_pos = pos;
 	
 	gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w);
 	
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl
index 2ec739802428663c3822619530637ee7738f52a5..45bfc0ce09c43a1ac80e7938fdf37ed6e4cf631b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl
@@ -22,7 +22,10 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_projection_matrix;
+uniform mat3 normal_matrix;
 
 attribute vec3 position;
 attribute vec3 normal;
@@ -33,10 +36,10 @@ varying vec3 vary_normal;
 void main()
 {
 	//transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0); 
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); 
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
-	vary_normal = normalize(gl_NormalMatrix * normal);
+	vary_normal = normalize(normal_matrix * normal);
 
 	gl_FrontColor = vec4(1,1,1,1);
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl
index 2f808b25db2877606e48915df18989e3e76cf3b8..ac51cb1741be2bb563651dafff0aba37291ae7d9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 
@@ -50,7 +52,7 @@ void main()
 {
 	//transform vertex
 	vec4 pos = vec4(position.xyz, 1.0);
-	mat4 modelViewProj = gl_ModelViewProjectionMatrix;
+	mat4 modelViewProj = modelview_projection_matrix;
 	
 	vec4 oPosition;
 		    
@@ -69,7 +71,7 @@ void main()
 		
 	oPosition = vec4(position, 1.0);
 	oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d);
-	vary_position = gl_ModelViewMatrix * oPosition;
+	vary_position = modelview_matrix * oPosition;
 	oPosition = modelViewProj * oPosition;
 	
 	refCoord.xyz = oPosition.xyz + vec3(0,0,0.2);
@@ -81,7 +83,7 @@ void main()
 	//push position for further horizon effect.
 	pos.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z);
 	pos.w = 1.0;
-	pos = gl_ModelViewMatrix*pos;
+	pos = modelview_matrix*pos;
 	
 	calcAtmospherics(pos.xyz);
 		
diff --git a/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl b/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl
index b5f6cb62d930a2069173eb325d267fdff9b42972..628489296facd8c1f902c50024c8b18fe6b0c0eb 100644
--- a/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl
+++ b/indra/newview/app_settings/shaders/class1/effects/glowExtractV.glsl
@@ -23,13 +23,15 @@
  * $/LicenseInfo$
  */
 
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec2 texcoord0;
 
 
 void main() 
 {
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position, 1.0);
 	
 	gl_TexCoord[0].xy = texcoord0;
 }
diff --git a/indra/newview/app_settings/shaders/class1/effects/glowV.glsl b/indra/newview/app_settings/shaders/class1/effects/glowV.glsl
index e8fd7a796d4ff3f7424c13e757dd639c26bb62aa..615ca6a0b4d10f849666763a54611feb36d987e7 100644
--- a/indra/newview/app_settings/shaders/class1/effects/glowV.glsl
+++ b/indra/newview/app_settings/shaders/class1/effects/glowV.glsl
@@ -23,6 +23,8 @@
  * $/LicenseInfo$
  */
  
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec2 texcoord0;
 
@@ -30,7 +32,7 @@ uniform vec2 glowDelta;
 
 void main() 
 {
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position, 1.0);
 	
 	gl_TexCoord[0].xy = texcoord0 + glowDelta*(-3.5);
 	gl_TexCoord[1].xy = texcoord0 + glowDelta*(-2.5);
diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl
index 8facc1ca963881c4aed1e6dcef40aae08165c229..04b3033dd8350a1fb91f62cf793bc78f1c497f97 100644
--- a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl
@@ -22,7 +22,15 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat3 normal_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 texture_matrix1;
+uniform mat4 texture_matrix2;
+uniform mat4 texture_matrix3;
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec3 normal;
 attribute vec4 diffuse_color;
@@ -51,17 +59,17 @@ vec4 texgen_object(vec4  vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
 void main()
 {
 	//transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 			
-	vec4 pos = gl_ModelViewMatrix * position;
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec4 pos = modelview_matrix * position;
+	vec3 norm = normalize(normal_matrix * normal);
 	
 	vec4 color = calcLighting(pos.xyz, norm, vec4(1,1,1,1), diffuse_color);
 	
 	gl_FrontColor = color;
 	
-	gl_TexCoord[0] = texgen_object(vec4(position.xyz, 1.0),vec4(texcoord0,0,1),gl_TextureMatrix[0],gl_ObjectPlaneS[0],gl_ObjectPlaneT[0]);
-	gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(texcoord1,0,1);
-	gl_TexCoord[2] = texgen_object(vec4(position.xyz, 1.0),vec4(texcoord2,0,1),gl_TextureMatrix[2],gl_ObjectPlaneS[2],gl_ObjectPlaneT[2]);
-	gl_TexCoord[3] = gl_TextureMatrix[3]*vec4(texcoord3,0,1);
+	gl_TexCoord[0] = texgen_object(vec4(position.xyz, 1.0),vec4(texcoord0,0,1),texture_matrix0,gl_ObjectPlaneS[0],gl_ObjectPlaneT[0]);
+	gl_TexCoord[1] = texture_matrix1*vec4(texcoord1,0,1);
+	gl_TexCoord[2] = texgen_object(vec4(position.xyz, 1.0),vec4(texcoord2,0,1),texture_matrix2,gl_ObjectPlaneS[2],gl_ObjectPlaneT[2]);
+	gl_TexCoord[3] = texture_matrix3*vec4(texcoord3,0,1);
 }
diff --git a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
index 831a7de0ea159114947505ff3fa4a07abbafef36..99433ada7bdce5c7de5c92b63d63fecd3477237e 100644
--- a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 
@@ -46,7 +48,7 @@ float wave(vec2 v, float t, float f, vec2 d, float s)
 void main()
 {
 	//transform vertex
-	mat4 modelViewProj = gl_ModelViewProjectionMatrix;
+	mat4 modelViewProj = modelview_projection_matrix;
 	
 	vec4 oPosition;
 		    
@@ -77,7 +79,7 @@ void main()
 	vec4 pos;
 	pos.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z);
 	pos.w = 1.0;
-	pos = gl_ModelViewMatrix*pos;
+	pos = modelview_matrix*pos;
 	
 	calcAtmospherics(pos.xyz);
 	
diff --git a/indra/newview/app_settings/shaders/class1/interface/customalphaV.glsl b/indra/newview/app_settings/shaders/class1/interface/customalphaV.glsl
index df67f76ad5ef4f95f679ca0b32d90b681296f16e..5bbc7deff03ac72d5df9f0179711785d816a1634 100644
--- a/indra/newview/app_settings/shaders/class1/interface/customalphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/customalphaV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec4 diffuse_color;
 attribute vec2 texcoord0;
@@ -30,7 +32,7 @@ attribute vec2 texcoord0;
 
 void main()
 {
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 	gl_TexCoord[0] = vec4(texcoord0,0,1);
 	gl_FrontColor = diffuse_color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/debugV.glsl b/indra/newview/app_settings/shaders/class1/interface/debugV.glsl
index 2f64fdb7bc66243d62e4aadc7525696aa3b6abc5..cd3d090e52a3e4313549170424d0d8362226bc42 100644
--- a/indra/newview/app_settings/shaders/class1/interface/debugV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/debugV.glsl
@@ -23,10 +23,12 @@
  * $/LicenseInfo$
  */
 
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 
 void main()
 {
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl
index f54876135e9b6bf3f29b6b3f8ea922e113c69c49..bd5dd6046b0aa6bf820c16558aa87f8bcae79bed 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineFXAAV.glsl
@@ -1,17 +1,37 @@
 /** 
  * @file glowcombineFXAAV.glsl
  *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+  * $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_tc;
 
 void main()
 {
-	vec4 pos = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
+	vec4 pos = modelview_projection_matrix*vec4(position.xyz, 1.0);
 	gl_Position = pos;
 
 	vary_tc = 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 303535ee31032b2f6169e25a3197b3c6517a2bd4..94edbe5ab1440a656b77607e1a0fadf188e074d3 100644
--- a/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/glowcombineV.glsl
@@ -22,14 +22,16 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec2 texcoord0;
 attribute vec2 texcoord1;
 
 void main()
 {
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 	gl_TexCoord[0] = vec4(texcoord0,0,1);
 	gl_TexCoord[1] = vec4(texcoord1,0,1);
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl
index 1d312313a84b8dfee708f39dc7571800eb8af88c..6bb5affd931741090ccd8d3552ded584c891af9d 100644
--- a/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl
@@ -22,14 +22,17 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec2 texcoord0;
 
 void main()
 {
 	//transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/interface/occlusionV.glsl b/indra/newview/app_settings/shaders/class1/interface/occlusionV.glsl
index 62fe4a2ce5b7a244b2170f7ad7ee2076cc101417..43dcd5dbe26cfae2110394489208bfafc1e243e1 100644
--- a/indra/newview/app_settings/shaders/class1/interface/occlusionV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/occlusionV.glsl
@@ -23,10 +23,12 @@
  * $/LicenseInfo$
  */
 
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 
 void main()
 {
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorV.glsl b/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorV.glsl
index 7df45e90e60737780cdf276baf21ca13a1cf9235..615412c7a2ef22c716f06d2d2e4363272fa5dca4 100644
--- a/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/onetexturenocolorV.glsl
@@ -2,9 +2,28 @@
  * @file onetexturenocolorV.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 vec2 texcoord0;
@@ -12,7 +31,7 @@ attribute vec2 texcoord0;
 
 void main()
 {
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position, 1);
+	gl_Position = modelview_projection_matrix * vec4(position, 1);
 	gl_TexCoord[0] = vec4(texcoord0,0,1);
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/interface/solidcolorV.glsl b/indra/newview/app_settings/shaders/class1/interface/solidcolorV.glsl
index be03d19290a5b166c4b9e207a1fc739061933de6..45e6a9febce108b9a9aaa0e7cc021290ce7b2975 100644
--- a/indra/newview/app_settings/shaders/class1/interface/solidcolorV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/solidcolorV.glsl
@@ -22,6 +22,8 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
+
+uniform mat4 modelview_projection_matrix;
  
 attribute vec3 position;
 attribute vec4 diffuse_color;
@@ -29,7 +31,7 @@ attribute vec2 texcoord0;
 
 void main()
 {
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 	gl_FrontColor = diffuse_color;
 	gl_TexCoord[0] = vec4(texcoord0,0,1);
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/splattexturerectV.glsl b/indra/newview/app_settings/shaders/class1/interface/splattexturerectV.glsl
index 085970f549e3850befa148d188a7adc9649601a4..2b471d99e8227f2165563872eff95b406b161ca2 100644
--- a/indra/newview/app_settings/shaders/class1/interface/splattexturerectV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/splattexturerectV.glsl
@@ -22,14 +22,16 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec2 texcoord0;
 attribute vec4 diffuse_color;
 
 void main()
 {
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 	gl_TexCoord[0] = vec4(texcoord0,0,1);
 	gl_FrontColor = diffuse_color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/twotextureaddV.glsl b/indra/newview/app_settings/shaders/class1/interface/twotextureaddV.glsl
index 80c57e77661c598a075ba9b19456afdc734cc638..2a36feaa2113b8c199c5d6fc959701d62c7c47c3 100644
--- a/indra/newview/app_settings/shaders/class1/interface/twotextureaddV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/twotextureaddV.glsl
@@ -23,6 +23,7 @@
  * $/LicenseInfo$
  */
  
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 attribute vec2 texcoord0;
@@ -30,7 +31,7 @@ attribute vec2 texcoord1;
 
 void main()
 {
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 	gl_TexCoord[0] = vec4(texcoord0,0,1);
 	gl_TexCoord[1] = vec4(texcoord1,0,1);
 }
diff --git a/indra/newview/app_settings/shaders/class1/interface/uiV.glsl b/indra/newview/app_settings/shaders/class1/interface/uiV.glsl
index faef21689e926ec035f3d0d627048b37add432e9..a9e42a432f071e709749ffe03e8ef7c0e9da8090 100644
--- a/indra/newview/app_settings/shaders/class1/interface/uiV.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/uiV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 attribute vec4 diffuse_color;
@@ -31,8 +33,8 @@ attribute vec2 texcoord0;
 
 void main()
 {
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position, 1);
-	gl_TexCoord[0] =  gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_Position = modelview_projection_matrix * vec4(position, 1);
+	gl_TexCoord[0] =  texture_matrix0 * vec4(texcoord0,0,1);
 	gl_FrontColor = diffuse_color;
 }
 
diff --git a/indra/newview/app_settings/shaders/class1/objects/bumpV.glsl b/indra/newview/app_settings/shaders/class1/objects/bumpV.glsl
index 7d38e07d65bbb1cb705dfa914f85e83cec3d012c..dccc692593043ba077baf10144215a3d507ea357 100644
--- a/indra/newview/app_settings/shaders/class1/objects/bumpV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/bumpV.glsl
@@ -22,7 +22,10 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 texture_matrix0;
+uniform mat4 texture_matrix1;
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 attribute vec2 texcoord0;
@@ -31,7 +34,7 @@ attribute vec2 texcoord1;
 void main()
 {
 	//transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
-	gl_TexCoord[1] = gl_TextureMatrix[1] * vec4(texcoord1,0,1);
+	gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
+	gl_TexCoord[1] = texture_matrix1 * vec4(texcoord1,0,1);
 }
diff --git a/indra/newview/app_settings/shaders/class1/objects/emissiveSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/objects/emissiveSkinnedV.glsl
index 78668711ac226ef1939b90b27c878ddf70580d65..e2a00e84407e9b2673bb61e4721a4d9869b9a7dc 100644
--- a/indra/newview/app_settings/shaders/class1/objects/emissiveSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/emissiveSkinnedV.glsl
@@ -1,10 +1,31 @@
 /** 
  * @file emissiveSkinnedV.glsl
  *
- * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
- * $License$
+ * $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 projection_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_matrix;
 
 attribute vec3 position;
 attribute float emissive;
@@ -16,18 +37,18 @@ mat4 getObjectSkinnedTransform();
 void main()
 {
 	//transform vertex
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
 	mat4 mat = getObjectSkinnedTransform();
 	
-	mat = gl_ModelViewMatrix * mat;
+	mat = modelview_matrix * mat;
 	vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
 	
 	calcAtmospherics(pos.xyz);
 
 	gl_FrontColor = vec4(0,0,0,emissive);
 	
-	gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
+	gl_Position = projection_matrix*vec4(pos, 1.0);
 		
 	gl_FogFragCoord = pos.z;
 }
diff --git a/indra/newview/app_settings/shaders/class1/objects/emissiveV.glsl b/indra/newview/app_settings/shaders/class1/objects/emissiveV.glsl
index 05d7cc397fd9397453e0e628658a1cf3a7087624..dedf00f37439ad9d01fbb98806216c3807932a9b 100644
--- a/indra/newview/app_settings/shaders/class1/objects/emissiveV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/emissiveV.glsl
@@ -1,10 +1,32 @@
 /**
  * @file emissiveV.glsl
  *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+  * $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 texture_matrix0;
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
+
 attribute vec4 position;
 attribute float emissive;
 attribute vec2 texcoord0;
@@ -17,10 +39,10 @@ void main()
 {
 	//transform vertex
 	vary_texture_index = position.w;
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
-	vec4 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0));
+	vec4 pos = (modelview_matrix * vec4(position.xyz, 1.0));
 	calcAtmospherics(pos.xyz);
 
 	gl_FrontColor = vec4(0,0,0,emissive);
diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightNoColorV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightNoColorV.glsl
index 57d98038e09a9ba2bd4691b2dc131ca69a35c651..b9c1078c309e23f8845442469fd4dffd5f50ffce 100644
--- a/indra/newview/app_settings/shaders/class1/objects/fullbrightNoColorV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightNoColorV.glsl
@@ -2,9 +2,31 @@
  * @file fullbrightNoColorV.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 texture_matrix0;
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec2 texcoord0;
 attribute vec3 normal;
@@ -15,9 +37,9 @@ void main()
 {
 	//transform vertex
 	vec4 vert = vec4(position.xyz,1.0);
-	vec4 pos = (gl_ModelViewMatrix * vert);
-	gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	vec4 pos = (modelview_matrix * vert);
+	gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 
 	calcAtmospherics(pos.xyz);
 
diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinySkinnedV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinySkinnedV.glsl
index ebbcb2f719d9b424c8dfff526eddd20ed99e6af5..546b7cad4affb670dc3b76a12e92c757c4f85944 100644
--- a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinySkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinySkinnedV.glsl
@@ -22,6 +22,10 @@
  * $/LicenseInfo$
  */
 
+uniform mat4 texture_matrix0;
+uniform mat4 texture_matrix1;
+uniform mat4 modelview_matrix;
+uniform mat4 projection_matrix;
 
 attribute vec3 position;
 attribute vec3 normal;
@@ -35,7 +39,7 @@ void main()
 {
 	mat4 mat = getObjectSkinnedTransform();
 	
-	mat = gl_ModelViewMatrix * mat;
+	mat = modelview_matrix * mat;
 	vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
 	
 	vec4 norm = vec4(position.xyz, 1.0);
@@ -45,14 +49,14 @@ void main()
 		
 	vec3 ref = reflect(pos.xyz, -norm.xyz);
 
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
-	gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
+	gl_TexCoord[1] = texture_matrix1*vec4(ref,1.0);
 
 	calcAtmospherics(pos.xyz);
 
 	gl_FrontColor = diffuse_color;
 	
-	gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
+	gl_Position = projection_matrix*vec4(pos, 1.0);
 	
 	gl_FogFragCoord = pos.z;
 }
diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyV.glsl
index e8126daee048c886a7004a3f9b462fd9fcebc842..a9b086e215ec2e4608df0df8be8c3f93bc4c55f3 100644
--- a/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightShinyV.glsl
@@ -22,7 +22,12 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat3 normal_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 texture_matrix1;
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 attribute vec4 diffuse_color;
@@ -36,15 +41,15 @@ uniform vec4 origin;
 void main()
 {
 	//transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 	
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec3 norm = normalize(normal_matrix * normal);
 	vec3 ref = reflect(pos.xyz, -norm);
 
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
-	gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
+	gl_TexCoord[1] = texture_matrix1*vec4(ref,1.0);
 
-	vec4 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0));
+	vec4 pos = (modelview_matrix * vec4(position.xyz, 1.0));
 	calcAtmospherics(pos.xyz);
 
 	gl_FrontColor = diffuse_color;
diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightSkinnedV.glsl
index 276f423eea97aafd16b2914321f88e7a4d6c8c36..f0722a1e4d8bcdabc0dfb30ecf0669d3a138c620 100644
--- a/indra/newview/app_settings/shaders/class1/objects/fullbrightSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightSkinnedV.glsl
@@ -22,6 +22,9 @@
  * $/LicenseInfo$
  */
 
+uniform mat4 projection_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_matrix;
 
 attribute vec3 position;
 attribute vec4 diffuse_color;
@@ -33,18 +36,18 @@ mat4 getObjectSkinnedTransform();
 void main()
 {
 	//transform vertex
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
 	mat4 mat = getObjectSkinnedTransform();
 	
-	mat = gl_ModelViewMatrix * mat;
+	mat = modelview_matrix * mat;
 	vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
 	
 	calcAtmospherics(pos.xyz);
 
 	gl_FrontColor = diffuse_color;
 	
-	gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
+	gl_Position = projection_matrix*vec4(pos, 1.0);
 		
 	gl_FogFragCoord = pos.z;
 }
diff --git a/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl b/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl
index 159e34f04485db91b9ae652aeddb01c1f12b0db2..d8f223d403ff758510519a8593a0193f05fae33f 100644
--- a/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/fullbrightV.glsl
@@ -22,7 +22,11 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec4 diffuse_color;
 attribute vec2 texcoord0;
@@ -32,9 +36,9 @@ void calcAtmospherics(vec3 inPositionEye);
 void main()
 {
 	//transform vertex
-	vec4 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0));
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	vec4 pos = (modelview_matrix * vec4(position.xyz, 1.0));
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
 
 
diff --git a/indra/newview/app_settings/shaders/class1/objects/impostorV.glsl b/indra/newview/app_settings/shaders/class1/objects/impostorV.glsl
index f175e3e76d8b909a0cdaa21fb6f8d2d9b555ca52..69007610c6e42cea868e320b01156a86f50de146 100644
--- a/indra/newview/app_settings/shaders/class1/objects/impostorV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/impostorV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_projection_matrix;
 
 
 attribute vec3 position;
@@ -31,6 +33,6 @@ attribute vec2 texcoord0;
 void main()
 {
 	//transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0, 0, 1);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0, 0, 1);
 }
diff --git a/indra/newview/app_settings/shaders/class1/objects/previewV.glsl b/indra/newview/app_settings/shaders/class1/objects/previewV.glsl
index 555c59c37ec0a92b1e7a77444a8e508f7c13a3f8..3771c2e795d38cadd5d1e31dacb156296df2bf87 100644
--- a/indra/newview/app_settings/shaders/class1/objects/previewV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/previewV.glsl
@@ -2,9 +2,32 @@
  * @file previewV.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 vec3 normal;
 attribute vec2 texcoord0;
@@ -15,11 +38,11 @@ void calcAtmospherics(vec3 inPositionEye);
 void main()
 {
 	//transform vertex
-	vec4 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0));
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	vec4 pos = (modelview_matrix * vec4(position.xyz, 1.0));
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 		
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec3 norm = normalize(normal_matrix * normal);
 
 	calcAtmospherics(pos.xyz);
 
diff --git a/indra/newview/app_settings/shaders/class1/objects/shinySimpleSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/objects/shinySimpleSkinnedV.glsl
index f0bea5f3e7d7666510c6e57a97bd05e38feb5f95..7e5c8ca2d595360eb0e04807a6653cec28889ea1 100644
--- a/indra/newview/app_settings/shaders/class1/objects/shinySimpleSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/shinySimpleSkinnedV.glsl
@@ -22,6 +22,11 @@
  * $/LicenseInfo$
  */
 
+uniform mat4 projection_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 texture_matrix1;
+uniform mat4 modelview_matrix;
+
 attribute vec3 position;
 attribute vec3 normal;
 attribute vec4 diffuse_color;
@@ -35,7 +40,7 @@ void main()
 {
 	mat4 mat = getObjectSkinnedTransform();
 	
-	mat = gl_ModelViewMatrix * mat;
+	mat = modelview_matrix * mat;
 	vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
 	
 	vec4 norm = vec4(position.xyz, 1.0);
@@ -45,13 +50,13 @@ void main()
 		
 	vec3 ref = reflect(pos.xyz, -norm.xyz);
 
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
-	gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
+	gl_TexCoord[1] = texture_matrix1*vec4(ref,1.0);
 
 	calcAtmospherics(pos.xyz);
 
 	vec4 color = calcLighting(pos.xyz, norm.xyz, diffuse_color, vec4(0.));
 	gl_FrontColor = color;
 	
-	gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
+	gl_Position = projection_matrix*vec4(pos, 1.0);
 }
diff --git a/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl b/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl
index e8b6b71b3d56b60b410f74ceed02b94bbff66c47..da47f8a58aa3c74c18b7566eb24f75dc5c63d156 100644
--- a/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl
@@ -22,7 +22,12 @@
  * 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 vec3 normal;
 attribute vec4 diffuse_color;
@@ -35,10 +40,10 @@ uniform vec4 origin;
 void main()
 {
 	//transform vertex
-	vec4 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0));
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	vec4 pos = (modelview_matrix * vec4(position.xyz, 1.0));
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 	
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec3 norm = normalize(normal_matrix * normal);
 
 	calcAtmospherics(pos.xyz);
 	
@@ -46,7 +51,7 @@ void main()
 	
 	vec3 ref = reflect(pos.xyz, -norm);
 	
-	gl_TexCoord[0] = gl_TextureMatrix[0]*vec4(ref,1.0);
+	gl_TexCoord[0] = texture_matrix0*vec4(ref,1.0);
 	
 	gl_FogFragCoord = pos.z;
 }
diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleNoColorV.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleNoColorV.glsl
index 54c262885e53a3f2fdc3e01031d77d82c626dcba..d1d8126cb464d18f4cf7e63468442f480a04f973 100644
--- a/indra/newview/app_settings/shaders/class1/objects/simpleNoColorV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/simpleNoColorV.glsl
@@ -2,9 +2,32 @@
  * @file simpleNoColorV.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 vec3 normal;
 attribute vec2 texcoord0;
@@ -15,11 +38,11 @@ void calcAtmospherics(vec3 inPositionEye);
 void main()
 {
 	//transform vertex
-	vec4 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0));
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	vec4 pos = (modelview_matrix * vec4(position.xyz, 1.0));
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 		
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec3 norm = normalize(normal_matrix * normal);
 
 	calcAtmospherics(pos.xyz);
 
diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleSkinnedV.glsl
index 14c4a3aa8d90d3f7d09813add51c3a88a29f9256..bf083a55c47e2352d3894f70671c89c1cf8e5e2d 100644
--- a/indra/newview/app_settings/shaders/class1/objects/simpleSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/simpleSkinnedV.glsl
@@ -22,6 +22,10 @@
  * $/LicenseInfo$
  */
 
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_matrix;
+uniform mat4 projection_matrix;
+
 attribute vec3 position;
 attribute vec3 normal;
 attribute vec4 diffuse_color;
@@ -34,11 +38,11 @@ mat4 getObjectSkinnedTransform();
 void main()
 {
 	//transform vertex
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
 	mat4 mat = getObjectSkinnedTransform();
 	
-	mat = gl_ModelViewMatrix * mat;
+	mat = modelview_matrix * mat;
 	vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
 	
 	vec4 norm = vec4(position.xyz, 1.0);
@@ -51,7 +55,7 @@ void main()
 	vec4 color = calcLighting(pos.xyz, norm.xyz, diffuse_color, vec4(0.));
 	gl_FrontColor = color;
 	
-	gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
+	gl_Position = projection_matrix*vec4(pos, 1.0);
 	
 	gl_FogFragCoord = pos.z;
 }
diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl
index bbc170b1af46b3a6b0c4816c6385546f1f109399..87ece3972ee228110e9d901c9f1612043abc4dbe 100644
--- a/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl
@@ -22,7 +22,12 @@
  * 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 vec3 normal;
 attribute vec4 diffuse_color;
@@ -34,11 +39,11 @@ void calcAtmospherics(vec3 inPositionEye);
 void main()
 {
 	//transform vertex
-	vec4 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0));
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	vec4 pos = (modelview_matrix * vec4(position.xyz, 1.0));
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 		
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec3 norm = normalize(normal_matrix * normal);
 
 	calcAtmospherics(pos.xyz);
 
diff --git a/indra/newview/app_settings/shaders/class1/objects/treeV.glsl b/indra/newview/app_settings/shaders/class1/objects/treeV.glsl
index 1e9e7f4b0b3c34b7642ac0969b8ee87cedb56808..64ca63731b1f906eb0bd4089eb3b098e76f4c61f 100644
--- a/indra/newview/app_settings/shaders/class1/objects/treeV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/treeV.glsl
@@ -2,10 +2,31 @@
  * @file treeV.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 vec2 texcoord0;
@@ -19,12 +40,12 @@ void main()
 	//transform vertex
 	vec4 vert = vec4(position.xyz,1.0);
 	
-	gl_Position = gl_ModelViewProjectionMatrix*vert;
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0, 0, 1);
+	gl_Position = modelview_projection_matrix*vert;
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0, 0, 1);
 	
-	vec4 pos = (gl_ModelViewMatrix * vert);
+	vec4 pos = (modelview_matrix * vert);
 	
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec3 norm = normalize(normal_matrix * normal);
 
 	calcAtmospherics(pos.xyz);
 
diff --git a/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl b/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl
index c0065f0bbe8f40c66965dda6586cf00d3429e0c5..43e19909d4ea99107f6ea30b6a8ff0814a8a8bee 100644
--- a/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl
+++ b/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl
@@ -22,7 +22,11 @@
  * 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;
@@ -35,11 +39,11 @@ void calcAtmospherics(vec3 inPositionEye);
 void main()
 {
 	//transform vertex
-	vec3 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0)).xyz;
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	vec3 pos = (modelview_matrix * vec4(position.xyz, 1.0)).xyz;
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 		
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec3 norm = normalize(normal_matrix * normal);
 
 	calcAtmospherics(pos.xyz);
 	
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
index 501fcb004b14d46a2fcd5a34b37d804692c32c7d..df4d26997acb3ce3287dd74a54f84479896dbb82 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
@@ -21,6 +21,11 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
+
+uniform mat4 projection_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
  
 attribute vec3 position;
 attribute vec3 normal;
@@ -79,15 +84,15 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
 
 void main()
 {
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
 	mat4 mat = getObjectSkinnedTransform();
 	
-	mat = gl_ModelViewMatrix * mat;
+	mat = modelview_matrix * mat;
 	
 	vec3 pos = (mat*vec4(position, 1.0)).xyz;
 	
-	gl_Position = gl_ProjectionMatrix * vec4(pos, 1.0);
+	gl_Position = projection_matrix * vec4(pos, 1.0);
 	
 	vec4 n = vec4(position, 1.0);
 	n.xyz += normal.xyz;
@@ -128,7 +133,7 @@ void main()
 
 	gl_FogFragCoord = pos.z;
 	
-	pos.xyz = (gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0)).xyz;
+	pos.xyz = (modelview_projection_matrix * vec4(position.xyz, 1.0)).xyz;
 	vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
 	
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
index b0ae0107fb2e181c7b06c8d84bff900fa7e41ecf..996203ffd6238d2f7d10dcbbe451e5c4a6d7340c 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
@@ -22,7 +22,12 @@
  * 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 vec4 position;
 attribute vec3 normal;
 attribute vec4 diffuse_color;
@@ -84,12 +89,12 @@ void main()
 	//transform vertex
 	vec4 vert = vec4(position.xyz, 1.0);
 	vary_texture_index = position.w;
-	vec4 pos = (gl_ModelViewMatrix * vert);
-	gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
+	vec4 pos = (modelview_matrix * vert);
+	gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
 	
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 		
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec3 norm = normalize(normal_matrix * normal);
 	
 	float dp_directional_light = max(0.0, dot(norm, gl_LightSource[0].position.xyz));
 	vary_position = pos.xyz + gl_LightSource[0].position.xyz * (1.0-dp_directional_light)*shadow_offset;
@@ -123,7 +128,7 @@ void main()
 
 	gl_FogFragCoord = pos.z;
 	
-	pos = gl_ModelViewProjectionMatrix * vert;
+	pos = modelview_projection_matrix * vert;
 	vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
 	
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
index f35af53f95273c01029aa39191bd7fbe294b0796..3e356757844da752bea4a0cbc6caae9886e21851 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
@@ -23,6 +23,7 @@
  * $/LicenseInfo$
  */
  
+uniform mat4 projection_matrix;
 
 attribute vec3 position;
 attribute vec3 normal;
@@ -99,7 +100,7 @@ void main()
 	norm.z = dot(trans[2].xyz, normal);
 	norm = normalize(norm);
 		
-	gl_Position = gl_ProjectionMatrix * pos;
+	gl_Position = projection_matrix * pos;
 	
 	float dp_directional_light = max(0.0, dot(norm, gl_LightSource[0].position.xyz));
 	vary_position = pos.xyz + gl_LightSource[0].position.xyz * (1.0-dp_directional_light)*shadow_offset;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/edgeV.glsl b/indra/newview/app_settings/shaders/class2/deferred/edgeV.glsl
index 964f12afcfd3d67eedbc5a270618be9ffa90856d..1f5470db3c349649edcac9047f4f12526c524a8c 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/edgeV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/edgeV.glsl
@@ -23,6 +23,7 @@
  * $/LicenseInfo$
  */
  
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 
@@ -32,7 +33,7 @@ uniform vec2 screen_res;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/softenLightV.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
index e52edcba412c998a25e91ebaf9f5843bec97a826..424299269fd3d0b18417d8ec3473e251c233fa07 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
@@ -22,7 +22,8 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 
@@ -33,7 +34,7 @@ varying vec2 vary_fragcoord;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
 	gl_Position = pos; 
 	
 	
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl
index 2cf7375d4d2b6a4d36bfec27ee8c94796ad976d7..60ba2d7ad4da88e6334402a0fcbe77808f3cad6e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 
 varying vec2 vary_fragcoord;
@@ -32,7 +34,7 @@ uniform vec2 screen_res;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/effects/blurV.glsl b/indra/newview/app_settings/shaders/class2/effects/blurV.glsl
index 556e131d3489e05dfa8f96fd268cc07482145e85..4fd4b101ff7abb5e3beb8e7aec4d77f17df612da 100644
--- a/indra/newview/app_settings/shaders/class2/effects/blurV.glsl
+++ b/indra/newview/app_settings/shaders/class2/effects/blurV.glsl
@@ -22,7 +22,8 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 attribute vec2 texcoord0;
@@ -34,7 +35,7 @@ uniform float blurWidth;
 void main(void)
 {
 	// Transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 	
 	vec2 blurDelta = texelSize * blurDirection * vec2(blurWidth, blurWidth);
 	vec2 s = vec4(texcoord0,0,1).st - (blurDelta * 3.0);
diff --git a/indra/newview/app_settings/shaders/class2/effects/drawQuadV.glsl b/indra/newview/app_settings/shaders/class2/effects/drawQuadV.glsl
index fbb87b6578793c91885f047f203d10e7d6322143..d3c93ab05f18a875dcbd56e44698e2b75a229a13 100644
--- a/indra/newview/app_settings/shaders/class2/effects/drawQuadV.glsl
+++ b/indra/newview/app_settings/shaders/class2/effects/drawQuadV.glsl
@@ -22,7 +22,8 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 attribute vec2 texcoord0;
@@ -32,7 +33,7 @@ attribute vec2 texcoord1;
 void main(void)
 {
 	//transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 	gl_TexCoord[0] = vec4(texcoord0,0,1);
 	gl_TexCoord[1] = vec4(texcoord1,0,1);
 }
diff --git a/indra/newview/app_settings/shaders/class2/environment/terrainV.glsl b/indra/newview/app_settings/shaders/class2/environment/terrainV.glsl
index 1a7edbd61b87ba8567f714908e59c9bf4497f9dc..69f4d4ae4580f9b23b665f8c4aabd8266605cf21 100644
--- a/indra/newview/app_settings/shaders/class2/environment/terrainV.glsl
+++ b/indra/newview/app_settings/shaders/class2/environment/terrainV.glsl
@@ -22,7 +22,11 @@
  * 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 vec3 normal;
@@ -52,10 +56,10 @@ vec4 texgen_object(vec4  vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
 void main()
 {
 	//transform vertex
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 
-	vec4 pos = gl_ModelViewMatrix * vec4(position.xyz, 1.0);
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec4 pos = modelview_matrix * vec4(position.xyz, 1.0);
+	vec3 norm = normalize(normal_matrix * normal);
 
 	calcAtmospherics(pos.xyz);
 
@@ -67,7 +71,7 @@ void main()
 	gl_FrontColor = color;
 
 	// Transform and pass tex coords
- 	gl_TexCoord[0].xy = texgen_object(vec4(position.xyz, 1.0), vec4(texcoord0,0,1), gl_TextureMatrix[0], gl_ObjectPlaneS[0], gl_ObjectPlaneT[0]).xy;
+ 	gl_TexCoord[0].xy = texgen_object(vec4(position.xyz, 1.0), vec4(texcoord0,0,1), texture_matrix0, gl_ObjectPlaneS[0], gl_ObjectPlaneT[0]).xy;
 	
 	vec4 t = vec4(texcoord1,0,1);
 	
diff --git a/indra/newview/app_settings/shaders/class2/objects/fullbrightShinyV.glsl b/indra/newview/app_settings/shaders/class2/objects/fullbrightShinyV.glsl
index 8a8895765918531893335a6b31acbcff1a4ff92a..b9eff87a13b21e42e55c6ca66644c4f988f1a291 100644
--- a/indra/newview/app_settings/shaders/class2/objects/fullbrightShinyV.glsl
+++ b/indra/newview/app_settings/shaders/class2/objects/fullbrightShinyV.glsl
@@ -22,7 +22,12 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat3 normal_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 texture_matrix1;
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
 
 
 void calcAtmospherics(vec3 inPositionEye);
@@ -41,14 +46,14 @@ void main()
 	//transform vertex
 	vec4 vert = vec4(position.xyz,1.0);
 	vary_texture_index = position.w;
-	vec4 pos = (gl_ModelViewMatrix * vert);
-	gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
+	vec4 pos = (modelview_matrix * vert);
+	gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
 	
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec3 norm = normalize(normal_matrix * normal);
 	vec3 ref = reflect(pos.xyz, -norm);
 
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
-	gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
+	gl_TexCoord[1] = texture_matrix1*vec4(ref,1.0);
 
 	calcAtmospherics(pos.xyz);
 
diff --git a/indra/newview/app_settings/shaders/class2/objects/fullbrightV.glsl b/indra/newview/app_settings/shaders/class2/objects/fullbrightV.glsl
index f5ff1d1d0083b561430d719d38b16a2148f51ab9..b7f7af7885b9bc5fbc3c2784e598caffa8e293b6 100644
--- a/indra/newview/app_settings/shaders/class2/objects/fullbrightV.glsl
+++ b/indra/newview/app_settings/shaders/class2/objects/fullbrightV.glsl
@@ -22,7 +22,10 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
  
 attribute vec4 position;
 attribute vec2 texcoord0;
@@ -39,9 +42,9 @@ void main()
 	//transform vertex
 	vec4 vert = vec4(position.xyz,1.0);
 	vary_texture_index = position.w;
-	vec4 pos = (gl_ModelViewMatrix * vert);
-	gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
+	vec4 pos = (modelview_matrix * vert);
+	gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
 	
 	calcAtmospherics(pos.xyz);
 
diff --git a/indra/newview/app_settings/shaders/class2/objects/shinyV.glsl b/indra/newview/app_settings/shaders/class2/objects/shinyV.glsl
index d6fca4cda7165793ddea4fbb8809d4b86dc48df7..4511c4bc91d2e40628c5825d67983c80cb01c937 100644
--- a/indra/newview/app_settings/shaders/class2/objects/shinyV.glsl
+++ b/indra/newview/app_settings/shaders/class2/objects/shinyV.glsl
@@ -22,7 +22,12 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat3 normal_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 texture_matrix1;
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
 
 attribute vec4 position;
 attribute vec2 texcoord0;
@@ -42,14 +47,14 @@ void main()
 	//transform vertex
 	vec4 vert = vec4(position.xyz,1.0);
 	vary_texture_index = position.w;
-	vec4 pos = (gl_ModelViewMatrix * vert);
-	gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
+	vec4 pos = (modelview_matrix * vert);
+	gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
 		
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec3 norm = normalize(normal_matrix * normal);
 	vec3 ref = reflect(pos.xyz, -norm);
 
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
-	gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0,0,1);
+	gl_TexCoord[1] = texture_matrix1*vec4(ref,1.0);
 
 	calcAtmospherics(pos.xyz);
 
diff --git a/indra/newview/app_settings/shaders/class2/objects/simpleNonIndexedV.glsl b/indra/newview/app_settings/shaders/class2/objects/simpleNonIndexedV.glsl
index d2a83c97249953eca659c4cd35fc432335641aad..5f78495ae36d1314d350bef8bb12230540f00f1d 100644
--- a/indra/newview/app_settings/shaders/class2/objects/simpleNonIndexedV.glsl
+++ b/indra/newview/app_settings/shaders/class2/objects/simpleNonIndexedV.glsl
@@ -2,10 +2,31 @@
  * @file simpleNonIndexedV.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 vec2 texcoord0;
@@ -20,12 +41,12 @@ void main()
 	//transform vertex
 	vec4 vert = vec4(position.xyz,1.0);
 	
-	gl_Position = gl_ModelViewProjectionMatrix*vert;
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0, 0, 1);
+	gl_Position = modelview_projection_matrix*vert;
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0, 0, 1);
 	
-	vec4 pos = (gl_ModelViewMatrix * vert);
+	vec4 pos = (modelview_matrix * vert);
 	
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec3 norm = normalize(normal_matrix * normal);
 
 	calcAtmospherics(pos.xyz);
 
diff --git a/indra/newview/app_settings/shaders/class2/objects/simpleV.glsl b/indra/newview/app_settings/shaders/class2/objects/simpleV.glsl
index c2db1e194955c3a65932e6b990473dec63c72629..91ee5e016e0b9b044a8c03aaaa2a87c723dc1a19 100644
--- a/indra/newview/app_settings/shaders/class2/objects/simpleV.glsl
+++ b/indra/newview/app_settings/shaders/class2/objects/simpleV.glsl
@@ -22,8 +22,11 @@
  * 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 vec4 position;
 attribute vec2 texcoord0;
@@ -40,13 +43,13 @@ void main()
 	//transform vertex
 	vec4 vert = vec4(position.xyz,1.0);
 	vary_texture_index = position.w;
-	vec4 pos = (gl_ModelViewMatrix * vert);
-	gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
-	gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0, 0, 1);
+	vec4 pos = (modelview_matrix * vert);
+	gl_Position = modelview_projection_matrix*vec4(position.xyz, 1.0);
+	gl_TexCoord[0] = texture_matrix0 * vec4(texcoord0, 0, 1);
 	
 	
 	
-	vec3 norm = normalize(gl_NormalMatrix * normal);
+	vec3 norm = normalize(normal_matrix * normal);
 
 	calcAtmospherics(pos.xyz);
 
diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
index 297b3904a60c70459823d38e3f4a21cc25c33669..67b5e7fb837e53863eef321efe1e17a65b1e9fa2 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec2 texcoord0;
 
@@ -60,7 +62,7 @@ void main()
 {
 
 	// World / view / projection
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 
 	gl_TexCoord[0] = vec4(texcoord0,0,1);
 
diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
index 84e1f827d6c2e6d6a0c0243ed300613675efa224..50fdba64c25f6a8b6e2ab58980b2dc79bf2f4615 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
@@ -23,6 +23,7 @@
  * $/LicenseInfo$
  */
  
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 attribute vec2 texcoord0;
@@ -59,7 +60,7 @@ void main()
 {
 
 	// World / view / projection
-	gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
 	gl_TexCoord[0] = vec4(texcoord0,0,1);
 
 	// Get relative position
diff --git a/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl b/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl
index f1d06b4fec883acc708dc8124c791078593867a1..c10635c898c879cb0fc9ce6903d5792ddb636376 100644
--- a/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl
+++ b/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 projection_matrix;
+
 attribute vec3 position;
 attribute vec3 normal;
 attribute vec2 texcoord0;
@@ -123,7 +125,7 @@ void main()
 	vec4 color = calcLighting(pos.xyz, norm, vec4(1,1,1,1), vec4(0.0));			
 	gl_FrontColor = color; 
 					
-	gl_Position = gl_ProjectionMatrix * pos;
+	gl_Position = projection_matrix * pos;
 	
 	
 	gl_TexCoord[2] = vec4(pos.xyz, 1.0);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/giDownsampleV.glsl b/indra/newview/app_settings/shaders/class3/deferred/giDownsampleV.glsl
index 870d4c36bcb22ef9b4813b7e09e3dd0997c69cf2..5e75aec171d888369f48be30612b1f9f21b0c482 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/giDownsampleV.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/giDownsampleV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 
 varying vec2 vary_fragcoord;
@@ -31,7 +33,7 @@ uniform vec2 screen_res;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/class3/deferred/giFinalV.glsl b/indra/newview/app_settings/shaders/class3/deferred/giFinalV.glsl
index 76206f88d9e5a2256fa56c29dbdf0d9af7b8bae8..969b6e2f1c0458afc60895c5dd8f2649462985e9 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/giFinalV.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/giFinalV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 
 
@@ -32,7 +34,7 @@ uniform vec2 screen_res;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/class3/deferred/giV.glsl b/indra/newview/app_settings/shaders/class3/deferred/giV.glsl
index 1a23be349eea05fd3e1b8e0d198a329055d2b595..2766691bd02b29eb3b0cbc9f599dc6cc82eaa2a2 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/giV.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/giV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 attribute vec4 diffuse_color;
 attribute vec2 texcoord0;
@@ -35,7 +37,7 @@ uniform vec2 screen_res;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/class3/deferred/luminanceV.glsl b/indra/newview/app_settings/shaders/class3/deferred/luminanceV.glsl
index a2606f2fb2d1385dd36538d62e6131b1fe7cda96..d0205fa824cbe5e7a37a45dff2823687dddcb9d6 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/luminanceV.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/luminanceV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 varying vec2 vary_fragcoord;
 
 uniform vec2 screen_res;
@@ -33,7 +35,7 @@ attribute vec4 diffuse_color;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/class3/deferred/postDeferredV.glsl b/indra/newview/app_settings/shaders/class3/deferred/postDeferredV.glsl
index 2d0b60d513b99f53cb19cdce5241042c904a67cf..2d7fa22edcb6170643b2e59d9fa12a3a9f2bf086 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/postDeferredV.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/postDeferredV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 
 varying vec2 vary_fragcoord;
@@ -31,7 +33,7 @@ uniform vec2 screen_res;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/class3/deferred/postgiV.glsl b/indra/newview/app_settings/shaders/class3/deferred/postgiV.glsl
index 25bdfdce453128836c4e1995f81238cc10080cc9..e9c6f3e27b8268af319dab7de442ff43f7a11ba9 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/postgiV.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/postgiV.glsl
@@ -22,7 +22,9 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
+
 attribute vec3 position;
 
 varying vec2 vary_fragcoord;
@@ -31,7 +33,7 @@ uniform vec2 screen_res;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/class3/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl
index 9e07a4d219fddbac9ef20d1bd40e499e609ac253..8e405de9a3d978e1ef7c07e8c10e418b7dcf9b9d 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl
@@ -22,7 +22,8 @@
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
+uniform mat4 modelview_projection_matrix;
 
 attribute vec3 position;
 attribute vec2 texcoord0;
@@ -34,7 +35,7 @@ varying vec2 vary_fragcoord;
 void main()
 {
 	//transform vertex
-	vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
+	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/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 917462c1ee79e4e7b2145eb9d5273407e45234e7..7155311f8ef4d1e2db5a69f734ecb0869e973597 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -380,7 +380,7 @@ void LLViewerShaderMgr::initAttribsAndUniforms(void)
 		mReservedUniforms.push_back("lastNormalGIMap");
 		mReservedUniforms.push_back("lastMinpGIMap");
 		mReservedUniforms.push_back("lastMaxpGIMap");
-					
+
 		mWLUniforms.push_back("camPosLocal");
 
 		mTerrainUniforms.reserve(5);