diff options
author | Dave Parks <davep@lindenlab.com> | 2024-09-03 19:47:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-03 17:47:32 -0700 |
commit | 891219dcef44583070e7487d0b6a4e57ad954667 (patch) | |
tree | 4fc80f504f5115c3c087e428d44f13e8a1bded0c /indra/newview | |
parent | 7c9c142a55f46351e9bc3dace9c2753fee6ed3c9 (diff) |
#1852 Fix for some visual corruption caused by divide by zero in lighting functions (#2488)
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index ab0e4fd4d8..3319e32cdf 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -99,10 +99,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); } |