From 9b511e87f5f3d52f430b89aa61860d5409469db7 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Mon, 26 Oct 2020 22:29:54 +0200
Subject: [PATCH] SL-13560 Water reflections do not reflect everything when ALM
 is enabled

Contribution
---
 doc/contributions.txt                                       | 3 ++-
 .../shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl  | 6 +++---
 .../class1/lighting/lightFullbrightWaterAlphaMaskF.glsl     | 4 ++--
 .../lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl  | 4 +++-
 .../shaders/class1/lighting/lightWaterAlphaMaskF.glsl       | 4 ++--
 .../class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl     | 4 ++--
 6 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/doc/contributions.txt b/doc/contributions.txt
index 07a96d8766b..28d702b38bd 100755
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -1347,7 +1347,8 @@ Sovereign Engineer
     MAINT-7343
     SL-11079
     OPEN-343
-	SL-11625
+    SL-11625
+    BUG-229030
 SpacedOut Frye
 	VWR-34
 	VWR-45
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl
index b768d609f47..d87403c78ff 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl
@@ -43,13 +43,13 @@ void default_lighting()
 {
 	vec4 color = texture2D(diffuseMap,vary_texcoord0.xy);
 
-	color *= vertex_color;
-
 	if (color.a < minimum_alpha)
 	{
 		discard;
 	}
-	
+
+	color *= vertex_color;
+
 	color.rgb = atmosLighting(color.rgb);
 
 	color.rgb = scaleSoftClip(color.rgb);
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl
index d04cd79f4b9..37cac5f4376 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterAlphaMaskF.glsl
@@ -43,13 +43,13 @@ void fullbright_lighting_water()
 {
 	vec4 color = diffuseLookup(vary_texcoord0.xy);
 
-	color.rgb *= vertex_color.rgb;
-
 	if (color.a < minimum_alpha)
 	{
 		discard;
 	}
 
+	color.rgb *= vertex_color.rgb;
+
 	color.rgb = fullbrightAtmosTransport(color.rgb);
 	
 	frag_color = applyWaterFog(color);
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl
index 3b9c04b22b9..c98db4795c6 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl
@@ -41,13 +41,15 @@ VARYING vec2 vary_texcoord0;
 
 void fullbright_lighting_water()
 {
-	vec4 color = texture2D(diffuseMap, vary_texcoord0.xy) * vertex_color;
+	vec4 color = texture2D(diffuseMap, vary_texcoord0.xy);
 
 	if (color.a < minimum_alpha)
 	{
 		discard;
 	}
 
+	color.rgb *= vertex_color.rgb;
+
 	color.rgb = fullbrightAtmosTransport(color.rgb);
 	
 	frag_color = applyWaterFog(color);
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl
index 09167972595..9c89c095737 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl
@@ -41,13 +41,13 @@ void default_lighting_water()
 {
 	vec4 color = diffuseLookup(vary_texcoord0.xy);
 
-	color.rgb *= vertex_color.rgb;
-
 	if (color.a < minimum_alpha)
 	{
 		discard;
 	}
 
+	color.rgb *= vertex_color.rgb;
+
 	color.rgb = atmosLighting(color.rgb);
 
 	frag_color = applyWaterFog(color);
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl
index f2a84f1d42f..9de7a031807 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl
@@ -43,13 +43,13 @@ void default_lighting_water()
 {
 	vec4 color = texture2D(diffuseMap,vary_texcoord0.xy);
 
-	color.rgb *= vertex_color.rgb;
-
 	if (color.a < minimum_alpha)
 	{
 		discard;
 	}
 
+	color.rgb *= vertex_color.rgb;
+
 	color.rgb = atmosLighting(color.rgb);
 
 	color = applyWaterFog(color);
-- 
GitLab