diff options
author | Graham Linden <graham@lindenlab.com> | 2019-03-25 14:52:23 -0700 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2019-03-25 14:52:23 -0700 |
commit | d99e2e119f08370b2003bad23617b7fdd435d19e (patch) | |
tree | 9bd5304cd306e07d4d05ff2d26c390b1da6d56a2 /indra | |
parent | 9c8cc0037a11861fa0561e8cda01d9ec7c996442 (diff) |
Add clamp to keep speccolor non-negative.
Make spot shadowing more consistent.
Diffstat (limited to 'indra')
3 files changed, 13 insertions, 14 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index ae2dd24b19..9112b6afd3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -135,13 +135,14 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe float sa = nh; float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; - float gtdenom = 2 * nh; + float gtdenom = abs(2 * nh); float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); - if (nh > 0.0) + if (gtdenom > 0.0) { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); vec3 speccol = lit*scol*light_col.rgb*spec.rgb; + speccol = max(speccol, vec3(0)); col += speccol; float cur_glare = max(speccol.r, speccol.g); diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 4e3ecbcbf5..c4f406aa76 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -154,10 +154,8 @@ void main() if (proj_shadow_idx >= 0) { vec4 shd = texture2DRect(lightMap, frag.xy); - float sh[2]; - sh[0] = shd.b; - sh[1] = shd.a; - shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0); + shadow = max(shd.b, shd.a) + shadow_fade; + shadow = clamp(shadow, 0.0, 1.0); } vec3 norm = texture2DRect(normalMap, frag.xy).xyz; @@ -255,8 +253,9 @@ void main() if (nh > 0.0) { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - col += dlit*scol*spec.rgb*shadow; - //col += spec.rgb; + vec3 speccol = dlit*scol*spec.rgb*shadow; + speccol = max(speccol, vec3(0)); + col += speccol; } } diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index abea8aecca..67eb503e72 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -154,10 +154,8 @@ void main() if (proj_shadow_idx >= 0) { vec4 shd = texture2DRect(lightMap, frag.xy); - float sh[2]; - sh[0] = shd.b; - sh[1] = shd.a; - shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0); + shadow = max(shd.b, shd.a) + shadow_fade; + shadow = min(shadow, 1.0); } vec3 norm = texture2DRect(normalMap, frag.xy).xyz; @@ -254,8 +252,9 @@ void main() if (nh > 0.0) { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - col += dlit*scol*spec.rgb*shadow; - //col += spec.rgb; + vec3 speccol = dlit*scol*spec.rgb*shadow; + speccol = max(speccol, vec3(0)); + col += speccol; } } |