aboutsummaryrefslogtreecommitdiffstats
path: root/test.frag
blob: 3b11ebb9e49e593499e2fd6c265011a558550551 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
uniform sampler2D sampler;

uniform int numLight;
uniform vec2 lightLocation[10];
uniform vec3 lightColor;
uniform float amb;
// uniform float lightStrength;
//uniform float screenHeight;
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);

		//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);

	color += vec4(amb,amb,amb,1.0f+amb);
	gl_FragColor = tex * vec4(color)*tex.a;
}