- adjusted lights so they are called to do something, instead of it being handled on game world - lights has only coordinate arguments + a table with all other optional ones. - renamed a lot of lights components to radius instaed of range, as it was agreed before elsewhere
26 lines
680 B
Lua
26 lines
680 B
Lua
shader = {}
|
|
shader.circle_gradient = love.graphics.newShader[[
|
|
uniform float pos_x;
|
|
uniform float pos_y;
|
|
uniform float radius;
|
|
uniform float scale;
|
|
|
|
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){
|
|
|
|
vec4 pixel = Texel(texture, texture_coords );//This is the current pixel color
|
|
|
|
float distance_x = pos_x - screen_coords.x / scale;
|
|
float distance_y = pos_y - screen_coords.y / scale;
|
|
float distance = sqrt( pow(distance_x,2) + pow(distance_y,2) ) ;
|
|
if (distance < radius){
|
|
float alpha = 1-(5*distance/radius);
|
|
if (pixel.a > alpha){
|
|
pixel.a = alpha;
|
|
}
|
|
} else {
|
|
pixel.a = 0;
|
|
}
|
|
return pixel * color * color;
|
|
}
|
|
]]
|