diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
index 438e1d1b33e28ea9e6b78674527b25086ad4d836..37dcbbd3281014ff3a92d2b1b91337460c663a29 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
@@ -27,8 +27,6 @@
 
 out vec4 frag_color;
 
-uniform sampler2D diffuseMap;
-
 void main()
 {
     frag_color = vec4(1,1,1,1);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index 8627ab1852f1ac98b6436cd0963f8e62e1c0febc..23a3ca4911ae18a27200b4fb5030ed8b51b0fb1a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -1,24 +1,24 @@
-/** 
+/**
  * @file blurLightF.glsl
  *
  * $LicenseInfo:firstyear=2007&license=viewerlgpl$
  * Second Life Viewer Source Code
  * Copyright (C) 2007, Linden Research, Inc.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation;
  * version 2.1 of the License only.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
@@ -27,7 +27,6 @@
 
 out vec4 frag_color;
 
-uniform sampler2D normalMap;
 uniform sampler2D lightMap;
 
 uniform float dist_factor;
@@ -42,16 +41,16 @@ in vec2 vary_fragcoord;
 vec4 getPosition(vec2 pos_screen);
 vec4 getNorm(vec2 pos_screen);
 
-void main() 
+void main()
 {
     vec2 tc = vary_fragcoord.xy;
     vec4 norm = getNorm(tc);
     vec3 pos = getPosition(tc).xyz;
     vec4 ccol = texture(lightMap, tc).rgba;
-  
+
     vec2 dlt = kern_scale * delta / (1.0+norm.xy*norm.xy);
     dlt /= max(-pos.z*dist_factor, 1.0);
-    
+
     vec2 defined_weight = kern[0].xy; // special case the first (centre) sample's weight in the blur; we have to sample it anyway so we get it for 'free'
     vec4 col = defined_weight.xyxx * ccol;
 
@@ -75,15 +74,15 @@ void main()
     k[1] = (k[0]+k[2])*0.5f;
     k[3] = (k[2]+k[4])*0.5f;
     k[5] = (k[4]+k[6])*0.5f;
-    
+
     for (int i = 1; i < 7; i++)
     {
         vec2 samptc = tc + k[i].z*dlt*2.0;
         samptc /= screen_res;
-        vec3 samppos = getPosition(samptc).xyz; 
+        vec3 samppos = getPosition(samptc).xyz;
 
         float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane
-        
+
         if (d*d <= pointplanedist_tolerance_pow2)
         {
             col += texture(lightMap, samptc)*k[i].xyxx;
@@ -95,10 +94,10 @@ void main()
     {
         vec2 samptc = tc - k[i].z*dlt*2.0;
         samptc /= screen_res;
-        vec3 samppos = getPosition(samptc).xyz; 
+        vec3 samppos = getPosition(samptc).xyz;
 
         float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane
-        
+
         if (d*d <= pointplanedist_tolerance_pow2)
         {
             col += texture(lightMap, samptc)*k[i].xyxx;
@@ -108,7 +107,7 @@ void main()
 
     col /= defined_weight.xyxx;
     //col.y *= col.y;
-    
+
     frag_color = max(col, vec4(0));
 
 #ifdef IS_AMD_CARD
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
index 183a736defe88d91d48a32255fedcec6dc1226f4..ef93d8063429d84326e3af9f4d11afe7afaf7df5 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
@@ -102,10 +102,13 @@ void calcHalfVectors(vec3 lv, vec3 n, vec3 v,
 {
     l  = normalize(lv);
     h  = normalize(l + v);
-    nh = clamp(dot(n, h), 0.0, 1.0);
-    nl = clamp(dot(n, l), 0.0, 1.0);
-    nv = clamp(dot(n, v), 0.0, 1.0);
-    vh = clamp(dot(v, h), 0.0, 1.0);
+
+    // lower bound to avoid divide by zero
+    float eps = 0.000001;
+    nh = clamp(dot(n, h), eps, 1.0);
+    nl = clamp(dot(n, l), eps, 1.0);
+    nv = clamp(dot(n, v), eps, 1.0);
+    vh = clamp(dot(v, h), eps, 1.0);
 
     lightDist = length(lv);
 }
@@ -484,6 +487,43 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
     return clamp(color, vec3(0), vec3(10));
 }
 
+vec3 pbrCalcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor,
+                    float perceptualRoughness,
+                    float metallic,
+                    vec3 n, // normal
+                    vec3 p, // pixel position
+                    vec3 v, // view vector (negative normalized pixel position)
+                    vec3 lp, // light position
+                    vec3 ld, // light direction (for spotlights)
+                    vec3 lightColor,
+                    float lightSize, float falloff, float is_pointlight, float ambiance)
+{
+    vec3 color = vec3(0,0,0);
+
+    vec3 lv = lp.xyz - p;
+
+    float lightDist = length(lv);
+
+    float dist = lightDist / lightSize;
+    if (dist <= 1.0)
+    {
+        lv /= lightDist;
+
+        float dist_atten = calcLegacyDistanceAttenuation(dist, falloff);
+
+        // spotlight coefficient.
+        float spot = max(dot(-ld, lv), is_pointlight);
+        // spot*spot => GL_SPOT_EXPONENT=2
+        float spot_atten = spot*spot;
+
+        vec3 intensity = spot_atten * dist_atten * lightColor * 3.0; //magic number to balance with legacy materials
+
+        color = intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv);
+    }
+
+    return color;
+}
+
 void calcDiffuseSpecular(vec3 baseColor, float metallic, inout vec3 diffuseColor, inout vec3 specularColor)
 {
     vec3 f0 = vec3(0.04);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl
index d0fc362db99c437355a0f13fa90d4ae454742f2e..ae179d3f375acf887cfc47e215c7c12b828e81c4 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl
@@ -51,8 +51,6 @@ uniform vec4[2] texture_emissive_transform;
 
 out vec3 vary_fragcoord;
 
-uniform float near_clip;
-
 in vec3 position;
 in vec4 diffuse_color;
 in vec3 normal;
@@ -88,7 +86,7 @@ void main()
 #endif
     gl_Position = vert;
 
-    vary_fragcoord.xyz = vert.xyz + vec3(0,0,near_clip);
+    vary_fragcoord.xyz = vert.xyz;
 
     base_color_texcoord = texture_transform(texcoord0, texture_base_color_transform, texture_matrix0);
     normal_texcoord = texture_transform(texcoord0, texture_normal_transform, texture_matrix0);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl
index 363d6bbe93ff5578aea4be723716ed26e70fd275..e77e97287319bc2e28ac0f097a66773cb94bfec6 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl
@@ -25,13 +25,13 @@
 
 // debug stub
 
-float random (vec2 uv) 
+float random (vec2 uv)
 {
-    return 0.0;
+    return 0.f;
 }
 
 float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n, inout vec4 collectedColor, sampler2D source, float glossiness)
 {
     collectedColor = vec4(0);
-    return 0.0;
+    return 0.f;
 }
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl
index 9db8f461dd3abb994a62538f349832796fc5c6b3..f208ac746b4d8c4a473f13c82d42563fa521d54e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl
@@ -27,8 +27,6 @@
 
 out vec4 frag_color;
 
-uniform sampler2D diffuseMap;
-
 in vec4 post_pos;
 in float target_pos_x;
 in vec4 vertex_color;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
index 16cc7cfbbc95d36fa13a7d708d98558640093ca1..6f7bd2bf3c03d8b6d11831cb116a30d1125e39b6 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl
@@ -24,7 +24,6 @@
  */
 
 uniform sampler2D   normalMap;
-uniform sampler2D   depthMap;
 
 #if defined(SUN_SHADOW)
 uniform sampler2DShadow shadowMap0;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl
index 7c02cb9d4aaddb4c9e9aa9b08d7372841ae6ddf2..298fe054f4dbdd1ebc1247a0e8ba6e64edf5a8ea 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl
@@ -1,24 +1,24 @@
-/** 
+/**
  * @file class1/deferred/textureUtilV.glsl
  *
  * $LicenseInfo:firstyear=2023&license=viewerlgpl$
  * Second Life Viewer Source Code
  * Copyright (C) 2023, Linden Research, Inc.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation;
  * version 2.1 of the License only.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
@@ -48,6 +48,7 @@ vec2 khr_texture_transform(vec2 texcoord, vec2 scale, float rotation, vec2 offse
     return (transform * vec3(texcoord, 1)).xy;
 }
 
+// A texture transform function for PBR materials applied to shape prims/Collada model prims
 // vertex_texcoord - The UV texture coordinates sampled from the vertex at
 //     runtime. Per SL convention, this is in a right-handed UV coordinate
 //     system. Collada models also have right-handed UVs.
@@ -93,6 +94,8 @@ vec2 terrain_texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform)
 // Take the rotation only from both transforms and apply to the tangent. This
 // accounts for the change of the topology of the normal texture when a texture
 // rotation is applied to it.
+// In practice, this applies the inverse of the texture transform to the tangent.
+// It is effectively an inverse of the rotation
 // *HACK: Assume the imported GLTF model did not have both normal texture
 // transforms and tangent vertices. The use of this function is inconsistent
 // with the GLTF sample viewer when that is the case. See getNormalInfo in
diff --git a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl
index 8073dfa7698b4e9df30ac0b99196d3102caeef82..a22ba967d569ad7aa3c42ce3d3fc74d6292203a6 100644
--- a/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/srgbF.glsl
@@ -23,8 +23,6 @@
  * $/LicenseInfo$
  */
 
- uniform sampler2D exposureMap;
-
 vec3 srgb_to_linear(vec3 cs)
 {
     vec3 low_range = cs / vec3(12.92);
diff --git a/indra/newview/app_settings/shaders/class1/interface/copyF.glsl b/indra/newview/app_settings/shaders/class1/interface/copyF.glsl
index edaa2488f04ac7de7d7de403d88d4df07670daaa..094d147e863ca3d1cafab68cbf033f8afa5d96b9 100644
--- a/indra/newview/app_settings/shaders/class1/interface/copyF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/copyF.glsl
@@ -25,7 +25,10 @@
 
 in vec2 tc;
 
+#if defined(COPY_DEPTH)
 uniform sampler2D depthMap;
+#endif
+
 uniform sampler2D diffuseMap;
 
 out vec4 frag_color;
diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
index d077670c96379b367150b7d3ba34736fb2dbf56c..359bfe8253c25884bc4d6ba0d7f7b70db0dee48f 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
@@ -57,9 +57,9 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou
 
     vec3  rel_pos_norm = normalize(rel_pos);
     float rel_pos_len  = length(rel_pos);
-    
+
     vec3  sunlight     = (sun_up_factor == 1) ? sunlight_color: moonlight_color;
-    
+
     // sunlight attenuation effect (hue and brightness) due to atmosphere
     // this is used later for sunlight modulation at various altitudes
     vec3 light_atten = (blue_density + vec3(haze_density * 0.25)) * (density_multiplier * max_y);
@@ -119,16 +119,19 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou
     additive = (blue_horizon.rgb * blue_weight.rgb) * (cs + tmpAmbient.rgb) + (haze_horizon * haze_weight.rgb) * (cs * haze_glow + tmpAmbient.rgb);
 
     // brightness of surface both sunlight and ambient
-    
+
     sunlit = sunlight.rgb;
     amblit = tmpAmbient;
 
     additive *= vec3(1.0 - combined_haze);
+
+    // sanity clamp haze contribution
+    additive = min(additive, vec3(10));
 }
 
 vec3 srgb_to_linear(vec3 col);
 
-// provide a touch of lighting in the opposite direction of the sun light 
+// provide a touch of lighting in the opposite direction of the sun light
     // so areas in shadow don't lose all detail
 float ambientLighting(vec3 norm, vec3 light_dir)
 {
@@ -150,7 +153,7 @@ void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, ou
     // (allows for mixing of light sources other than sunlight e.g. reflection probes)
     sunlit *= sky_sunlight_scale;
     amblit *= sky_ambient_scale;
-    
+
     amblit = srgb_to_linear(amblit);
     amblit *= ambientLighting(norm, light_dir);
 }
diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
index 5e2f70ff8b200b0f6c5b489c01caae821e5300f3..0339e1ab29ec10207a9c872363e6edd4d72caf37 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
@@ -1,24 +1,24 @@
-/** 
+/**
  * @file class1\deferred\pbralphaF.glsl
  *
  * $LicenseInfo:firstyear=2022&license=viewerlgpl$
  * Second Life Viewer Source Code
  * Copyright (C) 2022, Linden Research, Inc.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation;
  * version 2.1 of the License only.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
@@ -87,7 +87,7 @@ vec4 applySkyAndWaterFog(vec3 pos, vec3 additive, vec3 atten, vec4 color);
 void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist);
 float calcLegacyDistanceAttenuation(float distance, float falloff);
 float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen);
-void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, 
+void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv,
         vec2 tc, vec3 pos, vec3 norm, float glossiness, bool transparent, vec3 amblit_linear);
 
 void mirrorClip(vec3 pos);
@@ -111,15 +111,15 @@ vec3 pbrBaseLight(vec3 diffuseColor,
                   vec3 additive,
                   vec3 atten);
 
-vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, 
-                    float perceptualRoughness, 
+vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
+                    float perceptualRoughness,
                     float metallic,
                     vec3 n, // normal
                     vec3 v, // surface point to camera
                     vec3 l); //surface point to light
 
-vec3 calcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor, 
-                    float perceptualRoughness, 
+vec3 pbrCalcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor,
+                    float perceptualRoughness,
                     float metallic,
                     vec3 n, // normal
                     vec3 p, // pixel position
@@ -127,33 +127,7 @@ vec3 calcPointLightOrSpotLight(vec3 diffuseColor, vec3 specularColor,
                     vec3 lp, // light position
                     vec3 ld, // light direction (for spotlights)
                     vec3 lightColor,
-                    float lightSize, float falloff, float is_pointlight, float ambiance)
-{
-    vec3 color = vec3(0,0,0);
-
-    vec3 lv = lp.xyz - p;
-
-    float lightDist = length(lv);
-
-    float dist = lightDist / lightSize;
-    if (dist <= 1.0)
-    {
-        lv /= lightDist;
-
-        float dist_atten = calcLegacyDistanceAttenuation(dist, falloff);
-
-        // spotlight coefficient.
-        float spot = max(dot(-ld, lv), is_pointlight);
-        // spot*spot => GL_SPOT_EXPONENT=2
-        float spot_atten = spot*spot;
-
-        vec3 intensity = spot_atten * dist_atten * lightColor * 3.0; //magic number to balance with legacy materials
-
-        color = intensity*pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, n.xyz, v, lv);
-    }
-
-    return color;
-}
+                    float lightSize, float falloff, float is_pointlight, float ambiance);
 
 void main()
 {
@@ -181,7 +155,7 @@ void main()
     float sign = vary_sign;
     vec3 vN = vary_normal;
     vec3 vT = vary_tangent.xyz;
-    
+
     vec3 vB = sign * cross(vN, vT);
     vec3 norm = normalize( vNt.x * vT + vNt.y * vB + vNt.z * vN );
 
@@ -218,7 +192,7 @@ void main()
     vec3  irradiance = vec3(0);
     vec3  radiance  = vec3(0);
     sampleReflectionProbes(irradiance, radiance, vary_position.xy*0.5+0.5, pos.xyz, norm.xyz, gloss, true, amblit);
-    
+
     vec3 diffuseColor = vec3(0);
     vec3 specularColor = vec3(0);
     calcDiffuseSpecular(col.rgb, metallic, diffuseColor, specularColor);
@@ -230,7 +204,7 @@ void main()
     vec3 light = vec3(0);
 
     // Punctual lights
-#define LIGHT_LOOP(i) light += calcPointLightOrSpotLight(diffuseColor, specularColor, perceptualRoughness, metallic, norm.xyz, pos.xyz, v, light_position[i].xyz, light_direction[i].xyz, light_diffuse[i].rgb, light_deferred_attenuation[i].x, light_deferred_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w);
+#define LIGHT_LOOP(i) light += pbrCalcPointLightOrSpotLight(diffuseColor, specularColor, perceptualRoughness, metallic, norm.xyz, pos.xyz, v, light_position[i].xyz, light_direction[i].xyz, light_diffuse[i].rgb, light_deferred_attenuation[i].x, light_deferred_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w);
 
     LIGHT_LOOP(1)
     LIGHT_LOOP(2)
@@ -245,7 +219,7 @@ void main()
     color.rgb = applySkyAndWaterFog(pos.xyz, additive, atten, vec4(color, 1.0)).rgb;
 
     float a = basecolor.a*vertex_color.a;
-    
+
     frag_color = max(vec4(color.rgb,a), vec4(0));
 }
 
@@ -295,7 +269,7 @@ void main()
     // emissiveMap here is a vanilla RGB texture encoded as sRGB, manually convert to linear
     colorEmissive *= srgb_to_linear(texture(emissiveMap, emissive_texcoord.xy).rgb);
 
-    
+
     float a = basecolor.a*vertex_color.a;
     color += colorEmissive;
 
diff --git a/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl
index 4af57e3b80ac64a7b230ff11f95885d592ec964f..7b82aa1a0dca5bd7096a73813ce5c64c425d6481 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/hazeF.glsl
@@ -25,8 +25,6 @@
 
 out vec4 frag_color;
 
-uniform sampler2D normalMap;
-
 // Inputs
 uniform vec3 sun_dir;
 uniform vec3 moon_dir;
@@ -67,16 +65,16 @@ void main()
     calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten);
 
     vec3 sunlit_linear = srgb_to_linear(sunlit);
-    
+
     // mask off atmospherics below water (when camera is under water)
     bool do_atmospherics = false;
-        
+
     if (dot(vec3(0), waterPlane.xyz) + waterPlane.w > 0.0 ||
         dot(pos.xyz, waterPlane.xyz) + waterPlane.w > 0.0)
     {
         do_atmospherics = true;
     }
-    
+
     vec3  irradiance = vec3(0);
     vec3  radiance  = vec3(0);
 
@@ -101,5 +99,5 @@ void main()
     }
 
     frag_color = max(vec4(color.rgb, alpha), vec4(0)); //output linear since local lights will be added to this shader's results
-    
+
 }
diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
index 2d015bb372b403d5eaf301b22603cef4d969cba7..923327365a83bed708efec322e68a73e7d8c9838 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
@@ -77,7 +77,6 @@ uniform float is_mirror;
 
 uniform vec3 sun_dir;
 uniform vec3 moon_dir;
-in vec2 vary_fragcoord;
 
 uniform mat4 proj_mat;
 uniform mat4 inv_proj;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
index edfd6cbced9abf43ca9a75c635c31819f9b6efdf..4ed778371ff5fa9f232e32f079d08f8a651ec36d 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
@@ -27,7 +27,6 @@
 
 out vec4 frag_color;
 
-uniform sampler2D depthMap;
 uniform sampler2D diffuseRect;
 uniform sampler2D specularRect;
 uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
@@ -56,8 +55,8 @@ vec3 srgb_to_linear(vec3 c);
 // Util
 vec3 hue_to_rgb(float hue);
 
-vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, 
-                    float perceptualRoughness, 
+vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
+                    float perceptualRoughness,
                     float metallic,
                     vec3 n, // normal
                     vec3 v, // surface point to camera
@@ -91,7 +90,7 @@ void main()
         float metallic = orm.b;
         vec3 f0 = vec3(0.04);
         vec3 baseColor = diffuse.rgb;
-        
+
         vec3 diffuseColor = baseColor.rgb*(vec3(1.0)-f0);
         diffuseColor *= 1.0 - metallic;
 
diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
index 60be9f44070fdd4c3018576578b1b7c9264f1d05..6c137571497d5979ef525db35393668cfe5bc1b6 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
@@ -1,38 +1,36 @@
-/** 
+/**
  * @file class3\deferred\pointLightF.glsl
  *
  * $LicenseInfo:firstyear=2022&license=viewerlgpl$
  * Second Life Viewer Source Code
  * Copyright (C) 2022, Linden Research, Inc.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation;
  * version 2.1 of the License only.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
 /*[EXTRA_CODE_HERE]*/
 
 out vec4 frag_color;
 
 uniform sampler2D diffuseRect;
 uniform sampler2D specularRect;
-uniform sampler2D normalMap;
 uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
 uniform sampler2D lightFunc;
-uniform sampler2D depthMap;
 
 uniform vec3 env_mat[3];
 uniform float sun_wash;
@@ -59,8 +57,8 @@ vec2 getScreenCoord(vec4 clip);
 vec3 srgb_to_linear(vec3 c);
 float getDepth(vec2 tc);
 
-vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, 
-                    float perceptualRoughness, 
+vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
+                    float perceptualRoughness,
                     float metallic,
                     vec3 n, // normal
                     vec3 v, // surface point to camera
@@ -93,13 +91,13 @@ void main()
 
     if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
     {
-        vec3 colorEmissive = texture(emissiveRect, tc).rgb; 
+        vec3 colorEmissive = texture(emissiveRect, tc).rgb;
         vec3 orm = spec.rgb;
         float perceptualRoughness = orm.g;
         float metallic = orm.b;
         vec3 f0 = vec3(0.04);
         vec3 baseColor = diffuse.rgb;
-        
+
         vec3 diffuseColor = baseColor.rgb*(vec3(1.0)-f0);
         diffuseColor *= 1.0 - metallic;
 
@@ -136,7 +134,7 @@ void main()
                 final_color += lit*scol*color.rgb*spec.rgb;
             }
         }
-    
+
         if (dot(final_color, final_color) <= 0.0)
         {
             discard;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 9a683a646011865e448c561bce2681d59963d9c7..ba2411df1fd4e81ef99088a51b7dffc1fbf47839 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -29,7 +29,6 @@ out vec4 frag_color;
 
 uniform sampler2D diffuseRect;
 uniform sampler2D specularRect;
-uniform sampler2D normalMap;
 uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
 
 const float M_PI = 3.14159265;
@@ -38,7 +37,6 @@ const float M_PI = 3.14159265;
 uniform sampler2D lightMap;
 #endif
 
-uniform sampler2D depthMap;
 uniform sampler2D     lightFunc;
 
 uniform float blur_size;
@@ -105,8 +103,8 @@ vec3 pbrBaseLight(vec3 diffuseColor,
                   vec3 additive,
                   vec3 atten);
 
-vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, 
-                    float perceptualRoughness, 
+vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
+                    float perceptualRoughness,
                     float metallic,
                     vec3 n, // normal
                     vec3 v, // surface point to camera
@@ -169,15 +167,15 @@ void main()
 
     if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
     {
-        vec3 orm = spec.rgb; 
+        vec3 orm = spec.rgb;
         float perceptualRoughness = orm.g;
         float metallic = orm.b;
         float ao = orm.r;
 
-        
+
         // PBR IBL
         float gloss      = 1.0 - perceptualRoughness;
-        
+
         sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss, false, amblit_linear);
 
         adjustIrradiance(irradiance, ambocc);
@@ -205,7 +203,7 @@ void main()
     {
         // legacy shaders are still writng sRGB to gbuffer
         baseColor.rgb = srgb_to_linear(baseColor.rgb);
-        
+
         spec.rgb = srgb_to_linear(spec.rgb);
 
         float da          = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0);
@@ -224,7 +222,7 @@ void main()
         vec3 sun_contrib = min(da, scol) * sunlit_linear;
         color.rgb += sun_contrib;
         color.rgb *= baseColor.rgb;
-        
+
         vec3 refnormpersp = reflect(pos.xyz, norm.xyz);
 
         if (spec.a > 0.0)
@@ -254,7 +252,7 @@ void main()
         }
 
         color.rgb = mix(color.rgb, baseColor.rgb, baseColor.a);
-        
+
         if (envIntensity > 0.0)
         {  // add environment map
             applyLegacyEnv(color, legacyenv, spec, pos.xyz, norm.xyz, envIntensity);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
index 319fa86148b52951e4b579b55c239214871a0d24..bc4d36d10d31334bf4c9f6cd5897fdb91031b46b 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
@@ -1,40 +1,37 @@
-/** 
+/**
  * @file class3\deferred\spotLightF.glsl
  *
  * $LicenseInfo:firstyear=2022&license=viewerlgpl$
  * Second Life Viewer Source Code
  * Copyright (C) 2022, Linden Research, Inc.
- * 
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation;
  * version 2.1 of the License only.
- * 
+ *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  * $/LicenseInfo$
  */
- 
+
 /*[EXTRA_CODE_HERE]*/
 
 out vec4 frag_color;
 
 uniform sampler2D diffuseRect;
 uniform sampler2D specularRect;
-uniform sampler2D depthMap;
-uniform sampler2D normalMap;
 uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl
 uniform samplerCube environmentMap;
 uniform sampler2D lightMap;
-uniform sampler2D projectionMap; // rgba
 uniform sampler2D lightFunc;
 
 uniform mat4 proj_mat; //screen space to light space
@@ -83,8 +80,8 @@ vec4 getPosition(vec2 pos_screen);
 
 const float M_PI = 3.14159265;
 
-vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, 
-                    float perceptualRoughness, 
+vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
+                    float perceptualRoughness,
                     float metallic,
                     vec3 n, // normal
                     vec3 v, // surface point to camera
@@ -112,13 +109,13 @@ void main()
     }
 
     float shadow = 1.0;
-    
+
     if (proj_shadow_idx >= 0)
     {
         vec4 shd = texture(lightMap, tc);
         shadow = (proj_shadow_idx==0)?shd.b:shd.a;
         shadow += shadow_fade;
-        shadow = clamp(shadow, 0.0, 1.0);        
+        shadow = clamp(shadow, 0.0, 1.0);
     }
 
     vec4 norm = getNorm(tc);
@@ -149,7 +146,7 @@ void main()
         float metallic = orm.b;
         vec3 f0 = vec3(0.04);
         vec3 baseColor = diffuse.rgb;
-        
+
         vec3 diffuseColor = baseColor.rgb*(vec3(1.0)-f0);
         diffuseColor *= 1.0 - metallic;
 
@@ -167,7 +164,7 @@ void main()
             if (nl > 0.0)
             {
                 amb_da += (nl*0.5 + 0.5) * proj_ambiance;
-                
+
                 dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy );
 
                 vec3 intensity = dist_atten * dlit * 3.25 * shadow; // Legacy attenuation, magic number to balance with legacy materials
@@ -205,11 +202,11 @@ void main()
                 // unshadowed for consistency between forward and deferred?
                 amb_da += (nl*0.5+0.5) /* * (1.0-shadow) */ * proj_ambiance;
             }
-        
+
             amb_rgb = getProjectedLightAmbiance( amb_da, dist_atten, lit, nl, 1.0, proj_tc.xy );
             final_color += diffuse.rgb * amb_rgb * max(dot(-normalize(lv), n), 0.0);
         }
-    
+
         if (spec.a > 0.0)
         {
             dlit *= min(nl*6.0, 1.0) * dist_atten;
@@ -218,7 +215,7 @@ void main()
 
             float gtdenom = 2 * nh;
             float gt = max(0, min(gtdenom * nv / vh, gtdenom * nl / vh));
-                                
+
             if (nh > 0.0)
             {
                 float scol = fres*texture(lightFunc, vec2(nh, spec.a)).r*gt/(nh*nl);
@@ -226,26 +223,26 @@ void main()
                 speccol = clamp(speccol, vec3(0), vec3(1));
                 final_color += speccol;
             }
-        }   
+        }
 
         if (envIntensity > 0.0)
         {
             vec3 ref = reflect(normalize(pos), n);
-        
+
             //project from point pos in direction ref to plane proj_p, proj_n
             vec3 pdelta = proj_p-pos;
             float ds = dot(ref, proj_n);
-        
+
             if (ds < 0.0)
             {
                 vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds;
-            
+
                 vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0));
 
                 if (stc.z > 0.0)
                 {
                     stc /= stc.w;
-                                
+
                     if (stc.x < 1.0 &&
                         stc.y < 1.0 &&
                         stc.x > 0.0 &&
diff --git a/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl
index f6bef1e498baa13ec5747c10e57d4610a46f43d8..2bf785e773bde4507f6dca763151c797e74b381c 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/waterHazeF.glsl
@@ -28,8 +28,6 @@ out vec4 frag_color;
 // Inputs
 in vec4 vary_fragcoord;
 
-uniform sampler2D normalMap;
-
 vec4 getPositionWithDepth(vec2 pos_screen, float depth);
 float getDepth(vec2 pos_screen);
 
@@ -43,7 +41,7 @@ void main()
     float depth        = getDepth(tc.xy);
 
     if (above_water > 0)
-    { 
+    {
         // we want to depth test when the camera is above water, but some GPUs have a hard time
         // with depth testing against render targets that are bound for sampling in the same shader
         // so we do it manually here
@@ -60,5 +58,5 @@ void main()
     vec4 fogged = getWaterFogView(pos.xyz);
 
     frag_color = max(fogged, vec4(0)); //output linear since local lights will be added to this shader's results
-    
+
 }
diff --git a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl
index 728d70ebb2098bf6113079901a8d4780f5f93b3a..1c02dc764d7e05d29d0d6388ed09c74bdae007fb 100644
--- a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl
@@ -25,7 +25,6 @@
 
 out vec4 frag_color;
 
-uniform sampler2D diffuseMap;
 uniform sampler2D bumpMap;
 
 #ifdef TRANSPARENT_WATER