summaryrefslogtreecommitdiffstats
path: root/progs/glsl/shadowtex.frag.txt
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-02-03 11:36:16 -0700
committerBrian <[email protected]>2007-02-03 11:36:16 -0700
commitedf24e699ea75660eee0a62456ab2cbadf1b489f (patch)
tree45bee2dd5e0cd7f3e701322384c551fe8026f11b /progs/glsl/shadowtex.frag.txt
parent00d63aafc6d938f13acc9b136ff210fb0bbb15f9 (diff)
shading language texture demo/test
Diffstat (limited to 'progs/glsl/shadowtex.frag.txt')
-rw-r--r--progs/glsl/shadowtex.frag.txt21
1 files changed, 21 insertions, 0 deletions
diff --git a/progs/glsl/shadowtex.frag.txt b/progs/glsl/shadowtex.frag.txt
new file mode 100644
index 00000000000..a6a80da47f2
--- /dev/null
+++ b/progs/glsl/shadowtex.frag.txt
@@ -0,0 +1,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);
+}