From 0f379ae55e07d4e1e7904a3eb33b1c29c2177ec1 Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Fri, 18 Dec 2015 07:32:05 -0500 Subject: Added lights --- test.frag | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'test.frag') diff --git a/test.frag b/test.frag index 13fe6bc..18b03df 100644 --- a/test.frag +++ b/test.frag @@ -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 -- cgit v1.2.3