Changes on Lights

- 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
This commit is contained in:
lustlion
2022-03-17 00:37:14 +01:00
parent 0486787b98
commit f670f6bc87
3 changed files with 49 additions and 38 deletions

View File

@@ -2,7 +2,7 @@ shader = {}
shader.circle_gradient = love.graphics.newShader[[
uniform float pos_x;
uniform float pos_y;
uniform float range;
uniform float radius;
uniform float scale;
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){
@@ -12,11 +12,13 @@ shader.circle_gradient = love.graphics.newShader[[
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 < range){
float alpha = 1-(5*distance/range);
if (distance < radius){
float alpha = 1-(5*distance/radius);
if (pixel.a > alpha){
pixel.a = alpha;
}
} else {
pixel.a = 0;
}
return pixel * color * color;
}