diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2015-12-18 07:32:05 -0500 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2015-12-18 07:32:05 -0500 |
commit | 0f379ae55e07d4e1e7904a3eb33b1c29c2177ec1 (patch) | |
tree | 7e6b0303ec43fec9c19d54dd875c0e77b3681237 /test.frag | |
parent | f871cdcce267621adac4e5eb1f6705fd26462544 (diff) |
Added lights
Diffstat (limited to 'test.frag')
-rw-r--r-- | test.frag | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -1,4 +1,17 @@ -#version 120
-void main(){
- gl_FragColor = glColor;
-}
+uniform vec2 lightLocation;
+uniform vec3 lightColor;
+uniform float screenHeight;
+
+float radius = 4.9;
+float minLight = .01;
+float a = .01;
+float b = 1.0 / (radius*radius * minLight);
+
+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);
+
+ gl_FragColor = color;
+}
\ No newline at end of file |