File: shadowtex.frag

package info (click to toggle)
mesa 7.7.1-6
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 98,864 kB
  • ctags: 137,548
  • sloc: ansic: 736,522; cpp: 32,250; xml: 11,831; python: 10,446; asm: 8,599; makefile: 4,731; sh: 3,708; yacc: 2,226; lex: 495
file content (21 lines) | stat: -rw-r--r-- 487 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Fragment shader for 2D texture with shadow attenuation
// Brian Paul


uniform sampler2D tex2d;
uniform vec3 lightPos;

void main()
{
   // XXX should compute this from lightPos
   vec2 shadowCenter = vec2(-0.25, -0.25);

   // d = distance from center
   float d = distance(gl_TexCoord[0].xy, shadowCenter);

   // attenuate and clamp
   d = clamp(d * d * d, 0.0, 2.0);

   // modulate texture by d for shadow effect
   gl_FragColor = d * texture2D(tex2d, gl_TexCoord[0].xy, 0.0);
}