aboutsummaryrefslogtreecommitdiffstats
path: root/test.frag
diff options
context:
space:
mode:
Diffstat (limited to 'test.frag')
-rw-r--r--test.frag24
1 files changed, 17 insertions, 7 deletions
diff --git a/test.frag b/test.frag
index c6ff3c9..5c9054e 100644
--- a/test.frag
+++ b/test.frag
@@ -2,22 +2,23 @@
uniform sampler2D sampler;
uniform int numLight;
-uniform vec2 lightLocation[255];
+uniform vec2 lightLocation[1024];
uniform vec3 lightColor;
uniform float amb;
-// uniform float lightStrength;
-//uniform float screenHeight;
+
+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];
- //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);
+ //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;
- //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);
@@ -25,3 +26,12 @@ void main(){
color += vec4(amb,amb,amb,1.0f+amb);
gl_FragColor = tex * vec4(color)*tex.a;
}
+
+/* b values
+ .002 10
+ .008 50
+ .0005 200
+ .00008 500
+ .00002 1000
+ .00005 2000
+*/