1 // Fragment shader for 2D texture with shadow attenuation
5 uniform sampler2D tex2d;
10 // XXX should compute this from lightPos
11 vec2 shadowCenter = vec2(-0.25, -0.25);
13 // d = distance from center
14 float d = distance(gl_TexCoord[0].xy, shadowCenter);
16 // attenuate and clamp
17 d = clamp(d * d * d, 0.0, 2.0);
19 // modulate texture by d for shadow effect
20 gl_FragColor = d * texture2D(tex2d, gl_TexCoord[0].xy, 0.0);