From 6b54c48dff9a38a0a1410ed9bcd06d2667320df3 Mon Sep 17 00:00:00 2001
From: Geenz <geenz@geenzo.com>
Date: Mon, 1 Apr 2019 23:25:48 -0700
Subject: [PATCH] Scale the specular contribution to account for brighter
 highlights. This is more or less to achieve the non-ALM bloom behavior in
 most circumstances. Why scale it?  Normalized blinn-phong gets brighter the
 higher the specular exponent.  As it stood, the old spec contribution was
 extremely bright despite looking "correct".  This is largely eyeballed, but
 generally looks better for all light sources applied to the surface of the
 water.

---
 .../shaders/class1/deferred/softenLightF.glsl          |  2 +-
 .../app_settings/shaders/class1/deferred/waterF.glsl   | 10 ++--------
 .../shaders/class2/deferred/softenLightF.glsl          |  2 +-
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index a04a24955ed..cbeab3fc725 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -130,7 +130,7 @@ void main()
             
             // add the two types of shiny together
             vec3 spec_contrib = dumbshiny * spec.rgb;
-            bloom = dot(spec_contrib, spec_contrib) / 32;
+            bloom = dot(spec_contrib, spec_contrib) / 6;
             col += spec_contrib;
         }
         
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 9a8a098a195..c3c8683f6b6 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -142,13 +142,7 @@ void main()
     vec4 baseCol = texture2D(refTex, refvec4);
 
     refcol = mix(baseCol*df2, refcol, dweight);
-
-    //get specular component
-    float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0);
-        
-    //harden specular
-    spec = pow(spec, 128.0);
-
+    
     //figure out distortion vector (ripply)   
     vec2 distort2 = distort+wavef.xy*refScale * 0.33/max(dmod*df1, 1.0);
         
@@ -165,6 +159,6 @@ void main()
     vec3 screenspacewavef = normalize((norm_mat*vec4(wavef, 1.0)).xyz);
 
     frag_data[0] = vec4(color.rgb, 1); // diffuse
-    frag_data[1] = vec4(specular, 0.75);     // speccolor, spec
+    frag_data[1] = vec4(specular * 0.4, 0.75);     // speccolor, spec
     frag_data[2] = vec4(encode_normal(screenspacewavef.xyz), 0.05, 0);// normalxy, 0, 0
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 39776f17919..47fc20e2565 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -142,7 +142,7 @@ void main()
             
             // add the two types of shiny together
             vec3 spec_contrib = dumbshiny * spec.rgb;
-            bloom = dot(spec_contrib, spec_contrib) / 64;
+            bloom = dot(spec_contrib, spec_contrib) / 6;
             col += spec_contrib;
         }
         
-- 
GitLab