diff options
author | Graham Linden <graham@lindenlab.com> | 2019-05-04 10:56:16 -0700 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2019-05-04 10:56:16 -0700 |
commit | a4b279444e76432ca60553aaef861d9cb1773c06 (patch) | |
tree | b5c08370a20d6730550f2639b10810f64ef65087 /indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl | |
parent | 42397056089245da248d1aae6318239e90fbf866 (diff) |
SL-11080
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl index 14cd805d10..5694ba1f7b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl @@ -50,11 +50,10 @@ float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, { float offset = shadow_bias * bias_mul; stc.xyz /= stc.w; - stc.z += offset * 2.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 + stc.z += offset * 3.0; + stc.x = floor(stc.x*shadow_res.x + fract(pos_screen.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; - 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; @@ -112,8 +111,12 @@ 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; + float contrib = pcfShadow(shadowMap3, norm, lpos, 1.0, pos_screen, light_dir)*w; + if (contrib > 0) + { + shadow += contrib; + weight += w; + } shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); } @@ -125,8 +128,12 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) 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.0, 1.0); - shadow += pcfShadow(shadowMap2, norm, lpos, 1.0, pos_screen, light_dir)*w; - weight += w; + float contrib = pcfShadow(shadowMap2, norm, lpos, 1.0, pos_screen, light_dir)*w; + if (contrib > 0) + { + shadow += contrib; + weight += w; + } } if (spos.z < near_split.x && spos.z > far_split.y) @@ -137,8 +144,12 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) 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.0, 1.0); - shadow += pcfShadow(shadowMap1, norm, lpos, 1.0, pos_screen, light_dir)*w; - weight += w; + float contrib = pcfShadow(shadowMap1, norm, lpos, 1.0, pos_screen, light_dir)*w; + if (contrib > 0) + { + shadow += contrib; + weight += w; + } } if (spos.z > far_split.x) @@ -148,8 +159,12 @@ 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.0, 1.0); - shadow += pcfShadow(shadowMap0, norm, lpos, 1.0, pos_screen, light_dir)*w; - weight += w; + float contrib = pcfShadow(shadowMap0, norm, lpos, 1.0, pos_screen, light_dir)*w; + if (contrib > 0) + { + shadow += contrib; + weight += w; + } } shadow /= weight; |