From b3df764bd3c461df49f0f2289b66c87a76e71d34 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 15 May 2013 17:35:28 -0500
Subject: [PATCH] Attempt at making deferred rendering work on OpenGL 2.1

---
 .../shaders/class1/deferred/alphaF.glsl             | 12 ++++--------
 .../shaders/class1/deferred/alphaV.glsl             | 13 ++++---------
 indra/newview/featuretable.txt                      |  2 +-
 3 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 50b43f6a8d2..84e83d4c8b6 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -60,14 +60,10 @@ VARYING vec3 vary_ambient;
 VARYING vec3 vary_directional;
 VARYING vec3 vary_fragcoord;
 VARYING vec3 vary_position;
-VARYING vec3 vary_pointlight_col;
+VARYING vec4 vary_pointlight_col;
 VARYING vec2 vary_texcoord0;
 VARYING vec3 vary_norm;
 
-#ifdef USE_VERTEX_COLOR
-VARYING vec4 vertex_color;
-#endif
-
 uniform vec4 light_position[8];
 uniform vec3 light_direction[8];
 uniform vec3 light_attenuation[8]; 
@@ -216,7 +212,7 @@ void main()
 	diff.rgb = pow(diff.rgb, vec3(2.2f, 2.2f, 2.2f));
 
 #ifdef USE_VERTEX_COLOR
-	float vertex_color_alpha = vertex_color.a;	
+	float vertex_color_alpha = vary_pointlight_col.a;	
 #else
 	float vertex_color_alpha = 1.0;
 #endif
@@ -225,7 +221,7 @@ void main()
 	
 	vec3 l = light_position[0].xyz;
 	vec3 dlight = calcDirectionalLight(normal, l) * 2.6;
-	dlight = dlight * vary_directional.rgb * vary_pointlight_col;
+	dlight = dlight * vary_directional.rgb * vary_pointlight_col.rgb;
 
 #if HAS_SHADOW
 	vec4 col = vec4(vary_ambient + dlight * shadow, vertex_color_alpha);
@@ -250,7 +246,7 @@ void main()
 	LIGHT_LOOP(6)
 	LIGHT_LOOP(7)
 
-	color.rgb += diff.rgb * vary_pointlight_col * col.rgb;
+	color.rgb += diff.rgb * vary_pointlight_col.rgb * col.rgb;
 
 	frag_color = color;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 77d02b36ff1..9cc2eb0cf34 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -69,11 +69,8 @@ VARYING vec3 vary_ambient;
 VARYING vec3 vary_directional;
 VARYING vec3 vary_fragcoord;
 VARYING vec3 vary_position;
-VARYING vec3 vary_pointlight_col;
+VARYING vec4 vary_pointlight_col;
 
-#ifdef USE_VERTEX_COLOR
-VARYING vec4 vertex_color;
-#endif
 
 VARYING vec2 vary_texcoord0;
 
@@ -186,9 +183,9 @@ void main()
 
 	
 
-	vary_pointlight_col = diff;
+	vary_pointlight_col.rgb = diff;
+	vary_pointlight_col.a = vertex_color.a;
 
-	
 	col.rgb = vec3(0,0,0);
 
 	// Add windlight lights
@@ -200,9 +197,7 @@ void main()
 	
 	col.rgb = col.rgb*diff.rgb;
 	
-#ifdef USE_VERTEX_COLOR
-	vertex_color = col;
-#endif
+
 	
 #ifdef HAS_SKIN
 	vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip);
diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt
index 4030324ecbd..cd7825ba9f6 100755
--- a/indra/newview/featuretable.txt
+++ b/indra/newview/featuretable.txt
@@ -441,7 +441,7 @@ list OpenGLPre15
 RenderVBOEnable				1	0
 
 list OpenGLPre30
-RenderDeferred				0	0
+RenderDeferred				1	0
 RenderMaxTextureIndex		1	1
 
 list Intel
-- 
GitLab