light_world.lua/shader/poly_shadow.glsl

23 lines
687 B
Plaintext
Raw Normal View History

2014-03-04 13:52:51 +00:00
extern vec3 lightPositionRange;
extern vec3 lightColor;
extern float smooth;
extern vec2 glow;
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) {
if (glow.x < 1.0 && glow.y > 0.0) {
pixel.rgb = clamp(lightColor * pow(att, smooth) + pow(smoothstep(glow.x, 1.0, att), smooth) * glow.y, 0.0, 1.0);
2014-03-04 13:52:51 +00:00
} else {
pixel.rgb = lightColor * pow(att, smooth);
}
} else {
pixel.rgb = vec3(0, 0, 0);
}
return pixel;
}