Rehandled Darkness and Lights. Refactored lots of stuff. Rewritten shaders.

This commit is contained in:
lustlion
2022-02-21 18:24:20 +01:00
parent 192b1e6ca0
commit a944192f67
19 changed files with 166 additions and 202 deletions

View File

@@ -2,7 +2,7 @@ return {
name = "test",
tileset = tileset.library,
properties = {
darkness = false
darkness = true
},
tiles = {
{ 1, 4, 0, 0, 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},

View File

@@ -1,52 +1,23 @@
Shaders = {}
Shaders.InsideLight = love.graphics.newShader[[
uniform vec2 light_pos;
uniform vec3 light_color;
Shader = {}
Shader.RadiusGradient = love.graphics.newShader[[
uniform float pos_x;
uniform float pos_y;
uniform float range;
uniform float game_scale;
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 = light_pos.x - screen_coords.x;
float distance_y = light_pos.y - screen_coords.y;
float distance = sqrt( pow(distance_x,2) + pow(distance_y,2) ) / game_scale;
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-(distance/10);
pixel.a = alpha;
if (color.r<light_color.r){
color.r = light_color.r;
}
if (color.g<light_color.g){
color.g = light_color.g;
}
if (color.b<light_color.b){
color.b = light_color.b;
}
}
return pixel * color;
}
]]
Shaders.OutsideDark = love.graphics.newShader[[
uniform vec2 light_pos;
uniform float range;
uniform float game_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 = light_pos.x - screen_coords.x;
float distance_y = light_pos.y - screen_coords.y;
float distance = sqrt( pow(distance_x,2) + pow(distance_y,2) ) / game_scale;
if (distance < range){
float alpha = (distance/range);
float alpha = 1-(2*distance/range);
if (pixel.a > alpha){
pixel.a = alpha;
}
}
return pixel * color;
return pixel * color * color;
}
]]