summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl85
1 files changed, 61 insertions, 24 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
index 84e49a5f8f..aae6a070e2 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaNonIndexedF.glsl
@@ -23,10 +23,14 @@
* $/LicenseInfo$
*/
-
-
#extension GL_ARB_texture_rectangle : enable
+#ifdef DEFINE_GL_FRAGCOLOR
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor
+#endif
+
uniform sampler2DRectShadow shadowMap0;
uniform sampler2DRectShadow shadowMap1;
uniform sampler2DRectShadow shadowMap2;
@@ -42,11 +46,13 @@ uniform vec2 shadow_res;
vec3 atmosLighting(vec3 light);
vec3 scaleSoftClip(vec3 light);
-varying vec3 vary_ambient;
-varying vec3 vary_directional;
-varying vec3 vary_fragcoord;
-varying vec3 vary_position;
-varying vec3 vary_pointlight_col;
+VARYING vec3 vary_ambient;
+VARYING vec3 vary_directional;
+VARYING vec3 vary_fragcoord;
+VARYING vec3 vary_position;
+VARYING vec3 vary_pointlight_col;
+VARYING vec2 vary_texcoord0;
+VARYING vec4 vertex_color;
uniform float shadow_bias;
@@ -87,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;
@@ -96,36 +102,71 @@ 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,gl_TexCoord[0].xy);
- vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, gl_Color.a);
+ vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
+
+ vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, vertex_color.a);
vec4 color = diff * col;
color.rgb = atmosLighting(color.rgb);
@@ -134,10 +175,6 @@ void main()
color.rgb += diff.rgb * vary_pointlight_col.rgb;
- //gl_FragColor = gl_Color;
- gl_FragColor = color;
- //gl_FragColor.r = 0.0;
- //gl_FragColor = vec4(1,shadow,1,1);
-
+ frag_color = color;
}