aboutsummaryrefslogtreecommitdiffstats
path: root/test.frag
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-01-10 21:03:33 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-01-10 21:03:33 -0500
commit75a5569ed0d44494da379822aa5de519e4a4025b (patch)
tree1100ae214ad3a9eceac969d4796ef1ae825e8fb7 /test.frag
parent5c7c99ac5fe1158adbdf0469fb36ddd153511f5d (diff)
parenta0597ff41fb4be979f9dfd70ace8be98a737affb (diff)
Work on player texture
Diffstat (limited to 'test.frag')
-rw-r--r--test.frag29
1 files changed, 26 insertions, 3 deletions
diff --git a/test.frag b/test.frag
index c30ef4d..9bb5e3d 100644
--- a/test.frag
+++ b/test.frag
@@ -1,4 +1,27 @@
-#version 120
+#version 130
+uniform sampler2D sampler;
+
+uniform int numLight;
+uniform vec2 lightLocation[10];
+uniform vec3 lightColor;
+uniform float amb;
+// uniform float lightStrength;
+//uniform float screenHeight;
void main(){
- gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
-}
+ vec4 color = vec4(0.0f,0.0f,0.0f,0.0f);
+ for(int i = 0; i < numLight; i++){
+ vec2 loc = lightLocation[i];
+ //if(loc.x == 0.0f) continue;
+ float dist = length(loc - gl_FragCoord.xy);
+ float attenuation=1.0/(1.0+0.01*dist+0.00000000001*dist*dist);
+
+ //vec4 color = vec4(1.0f,1.0f,1.0f,1.0f);
+ color += vec4(attenuation, attenuation, attenuation, 1.0f) * vec4(lightColor, 1.0f);
+ //color = color + vec4((vec3(lightColor.r + amb, lightColor.g + amb, lightColor.b + amb)*0.25f),1.0f);
+ }
+ vec2 coords = gl_TexCoord[0].st;
+ vec4 tex = texture2D(sampler, coords);
+
+ color += vec4(amb,amb,amb,1.0f+amb);
+ gl_FragColor = tex * vec4(color)*tex.a;
+} \ No newline at end of file