aboutsummaryrefslogtreecommitdiffstats
path: root/frig.frag
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-01-19 07:33:46 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-01-19 07:33:46 -0500
commitfbd4ddbab2cc3a713430483b24642cbbc7050f0c (patch)
tree4fa2c7875240621b17f0dcf74d67066190dd7445 /frig.frag
parent1eced16d75322832617a1b42ec94580a9713e8f0 (diff)
Stuff
Diffstat (limited to 'frig.frag')
-rw-r--r--frig.frag39
1 files changed, 39 insertions, 0 deletions
diff --git a/frig.frag b/frig.frag
new file mode 100644
index 0000000..07b4a8a
--- /dev/null
+++ b/frig.frag
@@ -0,0 +1,39 @@
+#version 120
+uniform sampler2D sampler;
+
+uniform int numLight;
+uniform vec2 lightLocation[64];
+uniform vec3 lightColor;
+uniform float amb;
+
+float b = .0005;
+float minLight = .05;
+float radius = sqrt(1.0 / (b * minLight));
+
+//float radius = b*minlight;
+
+void main(){
+ vec4 color = vec4(0.0,0.0,0.0,0.0);
+ for(int i = 0; i < numLight; i++){
+ vec2 loc = lightLocation[i];
+ float dist = length(loc - gl_FragCoord.xy);
+ //float attenuation=1.0/(1.0+0.01*dist+0.00000000001*dist*dist);
+ float attenuation = clamp(1.0 - dist*dist/(radius*radius), 0.0, 1.0); attenuation *= attenuation;
+
+ color += vec4(attenuation, attenuation, attenuation, 1.0) * vec4(lightColor, 1.0);
+ }
+ vec2 coords = gl_TexCoord[0].st;
+ vec4 tex = texture2D(sampler, coords);
+
+ color += vec4(amb,amb,amb,1.0+amb);
+ gl_FragColor = tex * vec4(color)*tex.a;
+}
+
+/* b values
+ .002 10
+ .008 50
+ .0005 200
+ .00008 500
+ .00002 1000
+ .00005 2000
+*/ \ No newline at end of file