summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class2/deferred
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2010-04-07 12:41:44 -0500
committerDave Parks <davep@lindenlab.com>2010-04-07 12:41:44 -0500
commit70aa3cf12405eb7c0deaedce4dd2ced81ca3e0c8 (patch)
treecde2a09b68aeb037d1853157128e2b5f7317beeb /indra/newview/app_settings/shaders/class2/deferred
parent8a8269cca90df5bb7d53086ed7a3c14cb8cd941e (diff)
Shadow aliasing fix WIP
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred')
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl32
1 files changed, 29 insertions, 3 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 04c9a4d19a..4974bbef9e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -41,6 +41,9 @@ uniform vec2 proj_shadow_res;
uniform float shadow_bias;
uniform float shadow_offset;
+uniform float spot_shadow_bias;
+uniform float spot_shadow_offset;
+
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).a;
@@ -72,6 +75,24 @@ float pcfShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
//return shadow;
}
+float pcfSpotShadow(sampler2DRectShadow shadowMap, vec4 stc, float scl)
+{
+ stc.xyz /= stc.w;
+ stc.z += spot_shadow_bias*scl;
+
+ float cs = shadow2DRect(shadowMap, stc.xyz).x;
+ float shadow = cs;
+
+ shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(1.5, 1.5, 0.0)).x, cs);
+ shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(1.5, -1.5, 0.0)).x, cs);
+ shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-1.5, 1.5, 0.0)).x, cs);
+ shadow += max(shadow2DRect(shadowMap, stc.xyz+vec3(-1.5, -1.5, 0.0)).x, cs);
+
+ return shadow/5.0;
+
+ //return shadow;
+}
+
float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl)
{
stc.xyz /= stc.w;
@@ -114,7 +135,10 @@ void main()
float shadow = 1.0;
float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
- vec4 spos = vec4(pos.xyz + displace*norm + vary_light.xyz * (1.0-dp_directional_light)*shadow_offset, 1.0);
+ vec3 shadow_pos = pos.xyz + displace*norm;
+ vec3 offset = vary_light.xyz * (1.0-dp_directional_light);
+
+ vec4 spos = vec4(shadow_pos+offset*shadow_offset, 1.0);
if (spos.z > -shadow_clip.w)
{
@@ -176,13 +200,15 @@ void main()
gl_FragColor[0] = shadow;
gl_FragColor[1] = 1.0;
+ spos.xyz = shadow_pos*offset*spot_shadow_offset;
+
//spotlight shadow 1
vec4 lpos = shadow_matrix[4]*spos;
- gl_FragColor[2] = pcfShadow(shadowMap4, lpos, 0.8).x;
+ gl_FragColor[2] = pcfSpotShadow(shadowMap4, lpos, 0.8).x;
//spotlight shadow 2
lpos = shadow_matrix[5]*spos;
- gl_FragColor[3] = pcfShadow(shadowMap5, lpos, 0.8).x;
+ gl_FragColor[3] = pcfSpotShadow(shadowMap5, lpos, 0.8).x;
//gl_FragColor.rgb = pos.xyz;
//gl_FragColor.b = shadow;