From afdda55b8f6ad58c3e57185d3c352a923f4893aa Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Fri, 12 Jul 2019 14:45:15 -0700
Subject: [PATCH] SL-11588

Make avatar alpha shader ignore vertex color again.
---
 .../app_settings/shaders/class1/deferred/alphaF.glsl   |  8 +++++++-
 .../app_settings/shaders/class1/deferred/alphaV.glsl   | 10 ++++++++++
 indra/newview/llviewershadermgr.cpp                    |  5 ++++-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 759c49a0faa..0c4707098bf 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -53,7 +53,9 @@ VARYING vec3 vary_position;
 VARYING vec2 vary_texcoord0;
 VARYING vec3 vary_norm;
 
+#ifdef USE_VERTEX_COLOR
 VARYING vec4 vertex_color;
+#endif
 
 uniform mat4 proj_mat;
 uniform mat4 inv_proj;
@@ -203,9 +205,13 @@ void main()
     
     vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir;
 
-    float final_alpha = diffuse_linear.a * vertex_color.a;
+    float final_alpha = diffuse_linear.a;
+
+#ifdef USE_VERTEX_COLOR
+    final_alpha *= vertex_color.a;
     diffuse_srgb.rgb *= vertex_color.rgb;
     diffuse_linear.rgb *= vertex_color.rgb;
+#endif
 
     vec3 sunlit;
     vec3 amblit;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 619c4e97385..506118d381d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -40,7 +40,11 @@ void passTextureIndex();
 #endif
 
 ATTRIBUTE vec3 normal;
+
+#ifdef USE_VERTEX_COLOR
 ATTRIBUTE vec4 diffuse_color;
+#endif
+
 ATTRIBUTE vec2 texcoord0;
 
 #ifdef HAS_SKIN
@@ -53,7 +57,11 @@ mat4 getSkinnedTransform();
 
 VARYING vec3 vary_fragcoord;
 VARYING vec3 vary_position;
+
+#ifdef USE_VERTEX_COLOR
 VARYING vec4 vertex_color;
+#endif
+
 VARYING vec2 vary_texcoord0;
 VARYING vec3 vary_norm;
 
@@ -110,7 +118,9 @@ void main()
 	vary_norm = norm;
 	vary_position = pos.xyz;
 
+#ifdef USE_VERTEX_COLOR
 	vertex_color = diffuse_color;
+#endif
 	
 #ifdef HAS_SKIN
 	vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip);
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 5297e59e187..c874b3cf59c 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -1485,6 +1485,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		gDeferredSkinnedAlphaProgram.clearPermutations();
 		gDeferredSkinnedAlphaProgram.addPermutation("USE_DIFFUSE_TEX", "1");
 		gDeferredSkinnedAlphaProgram.addPermutation("HAS_SKIN", "1");
+        gDeferredSkinnedAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1");
 
 		if (use_sun_shadow)
 		{
@@ -1951,7 +1952,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
         gDeferredAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaF.glsl", GL_FRAGMENT_SHADER_ARB));
 
         gDeferredAlphaProgram.clearPermutations();
-
+        gDeferredAlphaProgram.addPermutation("USE_VERTEX_COLOR", "1");
         gDeferredAlphaProgram.addPermutation("USE_INDEXED_TEX", "1");
         if (use_sun_shadow)
         {
@@ -2012,6 +2013,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
         gDeferredAlphaImpostorProgram.clearPermutations();
         gDeferredAlphaImpostorProgram.addPermutation("USE_INDEXED_TEX", "1");
         gDeferredAlphaImpostorProgram.addPermutation("FOR_IMPOSTOR", "1");
+        gDeferredAlphaImpostorProgram.addPermutation("USE_VERTEX_COLOR", "1");
 
         if (use_sun_shadow)
         {
@@ -2060,6 +2062,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
 		gDeferredAlphaWaterProgram.clearPermutations();
 		gDeferredAlphaWaterProgram.addPermutation("USE_INDEXED_TEX", "1");
 		gDeferredAlphaWaterProgram.addPermutation("WATER_FOG", "1");
+        gDeferredAlphaWaterProgram.addPermutation("USE_VERTEX_COLOR", "1");
 		if (use_sun_shadow)
 		{
 			gDeferredAlphaWaterProgram.addPermutation("HAS_SHADOW", "1");
-- 
GitLab