From 22ec67975ccf7dd6da3dbddf94f503b14abee68e Mon Sep 17 00:00:00 2001
From: Ptolemy <ptolemy@lindenlab.com>
Date: Tue, 25 Feb 2020 11:34:23 -0800
Subject: [PATCH] SL-12574: Simplify Direct Ambient

---
 .../shaders/class1/deferred/softenLightF.glsl             | 8 ++------
 .../shaders/class2/deferred/softenLightF.glsl             | 8 ++------
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index b1dce665a12..705cc2f04e5 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -81,11 +81,7 @@ void main()
     norm.xyz = getNorm(tc);
     
     vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
-    float da = dot(normalize(norm.xyz), light_dir.xyz);
-          da = clamp(da, -1.0, 1.0);
-
-    float final_da = da;
-          final_da = clamp(final_da, 0.0, 1.0);
+    float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0);
 
     vec4 diffuse_srgb = texture2DRect(diffuseRect, tc);
     vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a);
@@ -108,7 +104,7 @@ void main()
         ambient *= ambient;
         ambient = (1.0 - ambient);
 
-        vec3 sun_contrib = final_da * sunlit;
+        vec3 sun_contrib = da * sunlit;
 
 #if !defined(AMBIENT_KILL)
         color.rgb = amblit;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index f49fad55171..593706867d1 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -85,11 +85,7 @@ void main()
     float scol = 1.0;
     vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
 
-    float da = dot(normalize(norm.xyz), light_dir.xyz);
-          da = clamp(da, -1.0, 1.0);
-
-    float final_da = da;
-          final_da = clamp(final_da, 0.0, 1.0);
+    float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0);
 
     vec4 diffuse_srgb   = texture2DRect(diffuseRect, tc);
     vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a);
@@ -116,7 +112,7 @@ void main()
         ambient *= ambient;
         ambient = (1.0 - ambient);
 
-        vec3 sun_contrib = min(scol, final_da) * sunlit;
+        vec3 sun_contrib = min(scol, da) * sunlit;
 
 #if !defined(AMBIENT_KILL)
         color.rgb = amblit;
-- 
GitLab