diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2016-01-07 08:25:49 -0500 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2016-01-07 08:25:49 -0500 |
commit | c7e3d72f0ef08cb9463cd8960bc29dad40e3bdcb (patch) | |
tree | d6bfde57916863ca9fd6fa2fbfae42338ae8e630 /test.frag | |
parent | 0f379ae55e07d4e1e7904a3eb33b1c29c2177ec1 (diff) | |
parent | 1b2510a427cea42e6381d60f434b5fdec2b181b0 (diff) |
Hey, that's pretty good lighting!
Diffstat (limited to 'test.frag')
-rw-r--r-- | test.frag | 28 |
1 files changed, 17 insertions, 11 deletions
@@ -1,17 +1,23 @@ +uniform sampler2D sampler;
+
uniform vec2 lightLocation;
uniform vec3 lightColor;
-uniform float screenHeight;
+uniform float amb;
+// uniform float lightStrength;
+//uniform float screenHeight;
+void main() {
+ float lightAdd = 1.0f;
-float radius = 4.9;
-float minLight = .01;
-float a = .01;
-float b = 1.0 / (radius*radius * minLight);
+ float dist = length(lightLocation - gl_FragCoord.xy);
+ float attenuation=1.0/(1.0+0.01*dist+0.00000000001*dist*dist);
-void main() {
- float distance = length(lightLocation - gl_FragCoord.xy);
- //float attenuation = 1.0 / (1.0 + a*distance + b*distance*distance);
- float attenuation = clamp(1.0 - distance*distance/(radius*radius), 0.0, 1.0); attenuation *= attenuation;
- vec4 color = vec4(attenuation, attenuation, attenuation, attenuation) * vec4(lightColor, 1);
+ //vec4 color = vec4(1.0f,1.0f,1.0f,1.0f);
+ vec4 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);
- gl_FragColor = color;
+ color += vec4(amb,amb,amb,1.0f+amb);
+ gl_FragColor = tex * vec4(color)*tex.a;
}
\ No newline at end of file |