From 360b3230bbfbda7988eee84a8ed04fa1696ca70a Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Wed, 22 May 2019 13:16:23 -0700
Subject: [PATCH] SL-11260

Make terrain underwater shader not try to light said terrain.

Fix colorspace of reflected color in non-ALM shading.

Tweak transparency of water further.
---
 .../app_settings/shaders/class1/deferred/waterF.glsl  | 11 ++++++-----
 .../shaders/class1/environment/terrainWaterF.glsl     |  5 ++++-
 .../shaders/class1/environment/waterF.glsl            |  7 +++----
 .../app_settings/shaders/class2/windlight/skyF.glsl   |  1 -
 indra/newview/llviewershadermgr.cpp                   |  2 ++
 5 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 0459b39bd92..2235ab12a43 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -153,24 +153,25 @@ void main()
 	spec = pow(spec, 128.0);
 
 	//figure out distortion vector (ripply)   
-	vec2 distort2 = distort+wavef.xy*(refScale*0.01)/max(dmod*df1, 1.0);
+	vec2 distort2 = distort+wavef.xy*refScale/max(dmod*df1, 1.0);
 		
 	vec4 fb = texture2D(screenTex, distort2);
 	
 	//mix with reflection
 	// Note we actually want to use just df1, but multiplying by 0.999999 gets around an nvidia compiler bug
-	color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.3 + 0.7);
+	color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.4 + 0.6);
 	
 	vec4 pos = vary_position;
 	
 	color.rgb += spec * specular;
 	
-	color.rgb = atmosTransport(color.rgb);
+	//color.rgb = atmosTransport(color.rgb);
 	color.rgb = scaleSoftClip(color.rgb);
-	color.a   = spec * sunAngle2 * 0.88;
 
+	color.a   = spec * sunAngle2;
+    
 	vec3 screenspacewavef = normalize((norm_mat*vec4(wavef, 1.0)).xyz);
-	
+
 	frag_data[0] = vec4(color.rgb, color); // diffuse
 	frag_data[1] = vec4(0);		// speccolor, spec
 	frag_data[2] = vec4(encode_normal(screenspacewavef.xyz*0.5+0.5), 0.05, 0);// normalxy, 0, 0
diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl
index 3b0c81fc71a..ddbe3ebe10e 100644
--- a/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl
@@ -59,7 +59,10 @@ void main()
 	vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal );
 	
 	/// Add WL Components
-	outColor.rgb = atmosLighting(outColor.rgb * vertex_color.rgb);
+	outColor.rgb *= vertex_color.rgb;
+
+    // SL-11260...
+	//outColor.rgb = atmosLighting(outColor.rgb);
 	
 	outColor = applyWaterFog(outColor);
 	frag_color = outColor;
diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
index 043815c8248..f033c0e7c41 100644
--- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
@@ -121,7 +121,6 @@ void main()
 
     vec4 refcol = refcol1 + refcol2 + refcol3;
     float df1 = df.x + df.y + df.z;
-    df1 *= 0.3333;
     refcol *= df1;
     
     vec3 wavef = (wave1 + wave2 * 0.4 + wave3 * 0.6) * 0.5;
@@ -151,11 +150,11 @@ void main()
     
     //mix with reflection
     // Note we actually want to use just df1, but multiplying by 0.999999 gets around and nvidia compiler bug
-    color.rgb = mix(fb.rgb, refcol.rgb, df1 + 0.6);
+    color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.4 + 0.6);
     color.rgb += spec * specular;
     
-    color.rgb = atmosTransport(color.rgb);
-    color.rgb = scaleSoftClip(color.rgb);
+    //color.rgb = atmosTransport(color.rgb);
+    color.rgb = scaleSoftClip(color.rgb * 0.5);
     color.a = spec * sunAngle2;
 
 #if defined(WATER_EDGE)
diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl
index 28d185b9af6..02e10b7b50b 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/skyF.glsl
@@ -50,7 +50,6 @@ void main()
 	vec4 color;
 	color = vary_HazeColor;
 	color *= 2.;
-
 	/// Gamma correct for WL (soft clip effect).
 	frag_color.rgb = scaleSoftClip(color.rgb);
 	frag_color.a = 1.0;
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 33572deebc5..c77a6315548 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -1095,6 +1095,7 @@ BOOL LLViewerShaderMgr::loadShadersWater()
 		gWaterProgram.mFeatures.calculatesAtmospherics = true;
 		gWaterProgram.mFeatures.hasGamma = true;
 		gWaterProgram.mFeatures.hasTransport = true;
+        gWaterProgram.mFeatures.hasSrgb = true;
 		gWaterProgram.mShaderFiles.clear();
 		gWaterProgram.mShaderFiles.push_back(make_pair("environment/waterV.glsl", GL_VERTEX_SHADER_ARB));
 		gWaterProgram.mShaderFiles.push_back(make_pair("environment/waterF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -1111,6 +1112,7 @@ BOOL LLViewerShaderMgr::loadShadersWater()
 		gWaterEdgeProgram.mFeatures.calculatesAtmospherics = true;
 		gWaterEdgeProgram.mFeatures.hasGamma = true;
 		gWaterEdgeProgram.mFeatures.hasTransport = true;
+        gWaterEdgeProgram.mFeatures.hasSrgb = true;
 		gWaterEdgeProgram.mShaderFiles.clear();
 		gWaterEdgeProgram.mShaderFiles.push_back(make_pair("environment/waterV.glsl", GL_VERTEX_SHADER_ARB));
 		gWaterEdgeProgram.mShaderFiles.push_back(make_pair("environment/waterF.glsl", GL_FRAGMENT_SHADER_ARB));
-- 
GitLab