diff options
| author | Graham Linden <graham@lindenlab.com> | 2019-04-23 13:12:16 -0700 | 
|---|---|---|
| committer | Graham Linden <graham@lindenlab.com> | 2019-04-23 13:12:16 -0700 | 
| commit | a685e024a62751289ccfa41c962b039d1de748bd (patch) | |
| tree | 1664379041cf03014e7becf1dd22c81e9f7ee0f7 /indra/newview/app_settings/shaders/class1 | |
| parent | 48f66434b84438b1d7146af4e6ba9d2c681153b6 (diff) | |
SL-10901
Bias shadow sampling and allow control of how dark shadows are (clamped ambient).
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
5 files changed, 25 insertions, 10 deletions
| diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index ab7f779a39..e8400ba66d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -83,6 +83,8 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o  float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen);  #endif +float getAmbientClamp(); +  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 @@ -209,7 +211,7 @@ void main()      float ambient = da;      ambient *= 0.5;      ambient *= ambient; -    ambient = max(0.66, ambient); // keeps shadows dark +    ambient = max(getAmbientClamp(), ambient); // keeps shadows dark      ambient = 1.0 - ambient;      vec3 sun_contrib = min(final_da, shadow) * sunlit; diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 0819f1b292..f1dbf4af46 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -83,6 +83,8 @@ uniform vec3 light_direction[8];  uniform vec4 light_attenuation[8];   uniform vec3 light_diffuse[8]; +float getAmbientClamp(); +  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 @@ -305,7 +307,7 @@ void main()      float ambient = da;      ambient *= 0.5;      ambient *= ambient; -    ambient = max(0.66, ambient); +    ambient = max(getAmbientClamp(), ambient);      ambient = 1.0 - ambient;      vec3 sun_contrib = min(final_da, shadow) * sunlit; diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl index 84032f7ff7..c2cb0eb8c3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl @@ -48,15 +48,17 @@ uniform int sun_up_factor;  float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir)  { +    float offset = shadow_bias * bias_mul;      stc.xyz /= stc.w; -    stc.z += shadow_bias * bias_mul * 2.0; +    stc.z += offset * 4.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; -    shadow += shadow2D(shadowMap, stc.xyz+vec3(2.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(-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; +    stc.z += offset * 2.0; +    shadow += shadow2D(shadowMap, stc.xyz+vec3( 1.5/shadow_res.x,  0.5/shadow_res.y, 0.0)).x; +    shadow += shadow2D(shadowMap, stc.xyz+vec3( 0.5/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; +    shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.5/shadow_res.x, -0.5/shadow_res.y, 0.0)).x; +    shadow += shadow2D(shadowMap, stc.xyz+vec3(-0.5/shadow_res.x,  1.5/shadow_res.y, 0.0)).x;      return clamp(shadow * 0.125, 0.0, 1.0);  } @@ -91,7 +93,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen)      vec3 offset = light_dir.xyz * (1.0 - dp_directional_light); -    shadow_pos += offset * shadow_offset; +    shadow_pos += offset * shadow_offset * 2.0;      vec4 spos = vec4(shadow_pos.xyz, 1.0); @@ -109,6 +111,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen)              float w = 1.0;              w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; +            w = clamp(w, 0.0, 1.0);              shadow += pcfShadow(shadowMap3, norm, lpos, 1.0, pos_screen, light_dir)*w;              weight += w;              shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); @@ -121,6 +124,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen)              float w = 1.0;              w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;              w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; +            w = clamp(w, 0.25, 1.0);              shadow += pcfShadow(shadowMap2, norm, lpos, 1.0, pos_screen, light_dir)*w;              weight += w;          } @@ -132,6 +136,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen)              float w = 1.0;              w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;              w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; +            w = clamp(w, 0.5, 1.0);              shadow += pcfShadow(shadowMap1, norm, lpos, 1.0, pos_screen, light_dir)*w;              weight += w;          } @@ -142,7 +147,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen)              float w = 1.0;              w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; -                 +            w = clamp(w, 0.75, 1.0);              shadow += pcfShadow(shadowMap0, norm, lpos, 1.0, pos_screen, light_dir)*w;              weight += w;          } diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 6f18244875..68deedd0d0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -70,6 +70,7 @@ vec4 applyWaterFogView(vec3 pos, vec4 color);  vec3 getNorm(vec2 pos_screen);  vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); +float getAmbientClamp();  void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten);  vec3 scaleSoftClipFrag(vec3 l); @@ -111,7 +112,7 @@ void main()          float ambient = da;          ambient *= 0.5;          ambient *= ambient; -        ambient = max(0.66, ambient); +        ambient = max(getAmbientClamp(), ambient);          ambient = 1.0 - ambient;          vec3 sun_contrib = final_da * sunlit; diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl index 07190d081e..09fb3e4c8a 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl @@ -42,6 +42,11 @@ uniform mat3 ssao_effect_mat;  uniform int no_atmo;  uniform float sun_moon_glow_factor; +float getAmbientClamp() +{ +    return 0.88f; +} +  void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten) {      vec3 P = inPositionEye; | 
