Mothback/data/shaders.lua

24 lines
649 B
Lua

Shader = {}
Shader.RadiusGradient = love.graphics.newShader[[
uniform float pos_x;
uniform float pos_y;
uniform float range;
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 < range){
float alpha = 1-(5*distance/range);
if (pixel.a > alpha){
pixel.a = alpha;
}
}
return pixel * color * color;
}
]]