From e08983ddccf0beee79e63bdf3ef1b839ea947c7a Mon Sep 17 00:00:00 2001
From: drumsetmonkey <abelleisle@roadrunner.com>
Date: Tue, 12 Jan 2016 07:37:19 -0500
Subject: Light posts

---
 test.frag | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

(limited to 'test.frag')

diff --git a/test.frag b/test.frag
index 083fc0b..80c741b 100644
--- a/test.frag
+++ b/test.frag
@@ -1,17 +1,22 @@
-#version 130
+#version 120
 uniform sampler2D sampler;
 
 uniform int numLight;
-uniform vec2 lightLocation[255];
+uniform vec2 lightLocation[1024];
 uniform vec3 lightColor;
 uniform float amb;
 
+float b = .0005;
+float minLight = .05;
+float radius = sqrt(1.0 / (b * minLight));
+
 void main(){
 	vec4 color = vec4(0.0f,0.0f,0.0f,0.0f);
 	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=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.0f) * vec4(lightColor, 1.0f);
 	}
@@ -20,4 +25,13 @@ void main(){
 
 	color += vec4(amb,amb,amb,1.0f+amb);
 	gl_FragColor = tex * vec4(color)*tex.a;
-}
\ No newline at end of file
+}
+
+/*b values
+	.002		10
+	.008 		50
+  	.0005		200
+ 	.00008		500
+  	.00002		1000
+	.00005		2000
+*/
\ No newline at end of file
-- 
cgit v1.2.3