2014-03-04 13:52:51 +00:00
|
|
|
extern vec3 lightPositionRange;
|
|
|
|
extern vec3 lightColor;
|
2014-03-09 03:22:45 +00:00
|
|
|
extern float lightSmooth;
|
|
|
|
extern vec2 lightGlow;
|
2014-03-04 13:52:51 +00:00
|
|
|
|
|
|
|
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords){
|
|
|
|
vec4 pixel = Texel(texture, texture_coords);
|
|
|
|
vec2 lightToPixel = pixel_coords - lightPositionRange.xy;
|
|
|
|
float distance = length(lightToPixel);
|
|
|
|
float att = 1 - distance / lightPositionRange.z;
|
|
|
|
|
|
|
|
if (distance <= lightPositionRange.z) {
|
2014-03-09 03:22:45 +00:00
|
|
|
if (lightGlow.x < 1.0 && lightGlow.y > 0.0) {
|
|
|
|
pixel.rgb = clamp(lightColor * pow(att, lightSmooth) + pow(smoothstep(lightGlow.x, 1.0, att), lightSmooth) * lightGlow.y, 0.0, 1.0);
|
2014-03-04 13:52:51 +00:00
|
|
|
} else {
|
2014-03-09 03:22:45 +00:00
|
|
|
pixel.rgb = lightColor * pow(att, lightSmooth);
|
2014-03-04 13:52:51 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pixel.rgb = vec3(0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pixel;
|
|
|
|
}
|