diff options
| author | Graham Linden <graham@lindenlab.com> | 2019-04-10 13:43:58 -0700 | 
|---|---|---|
| committer | Graham Linden <graham@lindenlab.com> | 2019-04-10 13:43:58 -0700 | 
| commit | 27184c74b4b8085e362c6e21d5d1071889476fe9 (patch) | |
| tree | bdd97b8ddb168e9017c1dbcbbbf77df0502e0d23 /indra/newview/app_settings/shaders/class1/deferred | |
| parent | 0b8ff3a8b22ccfdff320acba127ad631823b5644 (diff) | |
SL-10901
Fix up shadow sampling and tweak shadow biasing.
Clean up shader decls of unused funcs.
Clean up whitespace diffs from release.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
4 files changed, 22 insertions, 18 deletions
| diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index ca82dd9432..ab7f779a39 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -83,7 +83,7 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o  float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen);  #endif -vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance ,float shadow) +vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance)  {      //get light vector      vec3 lv = lp.xyz-v; @@ -115,15 +115,19 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec          // to match spotLight (but not multiSpotLight) *sigh*          float lit = max(da * dist_atten,0.0); -        col = lit * light_col * diffuse * shadow; +        col = lit * light_col * diffuse;          float amb_da = ambiance; -        amb_da += (da*0.5+0.5) * (1.0 - shadow) * ambiance; -        amb_da += (da*da*0.5 + 0.5) * (1.0 - shadow) * ambiance; +        if (da > 0) +        { +            amb_da += (da*0.5+0.5) * ambiance; +        } +        amb_da += (da*da*0.5 + 0.5) * ambiance;          amb_da *= dist_atten;          amb_da = min(amb_da, 1.0f - lit);          col.rgb += amb_da * 0.5 * light_col * diffuse; +          // no spec for alpha shader...      }      col = max(col, vec3(0)); @@ -185,6 +189,7 @@ void main()      vec3 atten;      calcAtmosphericVars(pos.xyz, 1.0, sunlit, amblit, additive, atten); +    sunlit *= 0.5;      vec2 abnormal = encode_normal(norm.xyz); @@ -228,9 +233,9 @@ vec3 post_diffuse = color.rgb;      vec4 light = vec4(0,0,0,0); -vec3 prelight_linearish_maybe = color.rgb; +vec3 prelight_linearish_maybe = srgb_to_linear(color.rgb); -   #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w * 0.5, 1.0); +   #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w * 0.5);      LIGHT_LOOP(1)      LIGHT_LOOP(2) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 9b07c11361..d14e67fc73 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -83,7 +83,7 @@ uniform vec3 light_direction[8];  uniform vec4 light_attenuation[8];   uniform vec3 light_diffuse[8]; -vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare, float ambiance, float shadow) +vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare, float ambiance)  {      //get light vector      vec3 lv = lp.xyz-v; @@ -109,17 +109,16 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe          // spotlight coefficient.          float spot = max(dot(-ln, lv), is_pointlight); -        da *= spot*spot; // GL_SPOT_EXPONENT=2          //angular attenuation          da = dot(n, lv);          da = clamp(da, 0.0, 1.0); +        da *= spot*spot; // GL_SPOT_EXPONENT=2 +          float lit = max(da * dist_atten, 0.0); -        // shadowmap is wrong for alpha-blended objs -        // since we created shadowmaps for 2 but render N -        col = light_col*lit*diffuse*shadow; +        col = light_col*lit*diffuse;          float amb_da = ambiance;          if (da > 0) @@ -148,7 +147,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe              {                  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)); +                speccol = clamp(speccol, vec3(0), vec3(1));                  col += speccol;                  float cur_glare = max(speccol.r, speccol.g); @@ -372,9 +371,9 @@ vec3 post_spec = col.rgb;      vec3 light = vec3(0,0,0); -    vec3 prelight_linearish_maybe = col.rgb; +    vec3 prelight_linearish_maybe = srgb_to_linear(col.rgb); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w * 0.5, 1.0); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w * 0.5);          LIGHT_LOOP(1)          LIGHT_LOOP(2) diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl index 642aff6c41..0a714f0013 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl @@ -49,7 +49,7 @@ uniform int sun_up_factor;  float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir)  {      stc.xyz /= stc.w; -    stc.z += shadow_bias * bias_mul * 2.0; +    stc.z += shadow_bias * bias_mul * 16.0;      stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here      float cs = shadow2D(shadowMap, stc.xyz).x;      float shadow = cs * 4.0; @@ -57,7 +57,7 @@ float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul,      shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x;      shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x;      shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; -    return shadow * 0.125; +    return clamp(shadow * 0.125, 0.0, 1.0);  }  float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 pos_screen) diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index ff30004ffd..476a1216d3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -151,8 +151,8 @@ vec3 post_diffuse = col.rgb;              {                  float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);                  vec3 speccol = sun_contrib*scol*spec.rgb; -                speccol = max(speccol, vec3(0)); -                bloom = dot (speccol, speccol) / 2; +                speccol = clamp(speccol, vec3(0), vec3(1)); +                bloom = dot(speccol, speccol) / 2;                  col += speccol;              }          } | 
