Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

shadowtex.frag 487B

123456789101112131415161718192021
  1. // Fragment shader for 2D texture with shadow attenuation
  2. // Brian Paul
  3. uniform sampler2D tex2d;
  4. uniform vec3 lightPos;
  5. void main()
  6. {
  7. // XXX should compute this from lightPos
  8. vec2 shadowCenter = vec2(-0.25, -0.25);
  9. // d = distance from center
  10. float d = distance(gl_TexCoord[0].xy, shadowCenter);
  11. // attenuate and clamp
  12. d = clamp(d * d * d, 0.0, 2.0);
  13. // modulate texture by d for shadow effect
  14. gl_FragColor = d * texture2D(tex2d, gl_TexCoord[0].xy, 0.0);
  15. }