diff options
author | Dave Parks <davep@lindenlab.com> | 2012-02-17 19:40:48 -0600 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2012-02-17 19:40:48 -0600 |
commit | 48f5b69c43d4d4a2b6e272f7ac8d706ccc0c0601 (patch) | |
tree | 5d4c1f717d110e20b866901ee3a9fb9eb846293c /indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl | |
parent | 6ecae04d358cc27bc4890778a1493b3818236fb9 (diff) |
SH-2915 Smoother transition between sun shadow splits.
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl')
-rw-r--r-- | indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl index c467e6c5cb..aae6a070e2 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl @@ -93,7 +93,7 @@ void main() vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; frag *= screen_res; - float shadow = 1.0; + float shadow = 0.0; vec4 pos = vec4(vary_position, 1.0); vec4 spos = pos; @@ -102,33 +102,68 @@ void main() { vec4 lpos; - if (spos.z < -shadow_clip.z) + vec4 near_split = shadow_clip*-0.75; + vec4 far_split = shadow_clip*-1.25; + vec4 transition_domain = near_split-far_split; + float weight = 0.0; + + if (spos.z < near_split.z) { lpos = shadow_matrix[3]*spos; lpos.xy *= shadow_res; - shadow = pcfShadow(shadowMap3, lpos, 1.5); + + float w = 1.0; + w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; + shadow += pcfShadow(shadowMap3, lpos, 0.25)*w; + weight += w; shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); } - else if (spos.z < -shadow_clip.y) + + if (spos.z < near_split.y && spos.z > far_split.z) { lpos = shadow_matrix[2]*spos; lpos.xy *= shadow_res; - shadow = pcfShadow(shadowMap2, lpos, 1.5); + + 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; + shadow += pcfShadow(shadowMap2, lpos, 0.75)*w; + weight += w; } - else if (spos.z < -shadow_clip.x) + + if (spos.z < near_split.x && spos.z > far_split.y) { lpos = shadow_matrix[1]*spos; lpos.xy *= shadow_res; - shadow = pcfShadow(shadowMap1, lpos, 1.5); + + 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; + shadow += pcfShadow(shadowMap1, lpos, 0.75)*w; + weight += w; } - else + + if (spos.z > far_split.x) { lpos = shadow_matrix[0]*spos; lpos.xy *= shadow_res; - shadow = pcfShadow(shadowMap0, lpos, 1.5); + + float w = 1.0; + w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; + + shadow += pcfShadow(shadowMap0, lpos, 1.0)*w; + weight += w; } + + + shadow /= weight; + } - + else + { + shadow = 1.0; + } + vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, vertex_color.a); |