shader_type canvas_item;

uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
uniform float brightness_multiplier : hint_range(1.0, 10.0) = 3.0;

void fragment() {
    // 1. Get the color of the darkened floor behind the sprite
    vec4 background = texture(screen_texture, SCREEN_UV);
    
    // 2. Get the shape/fading of your light texture
    // We use the 'r' channel or 'a' channel depending on your sprite
    float mask = texture(TEXTURE, UV).a;
    
    // 3. Instead of adding white, we multiply the background pixels
    // This restores the original colors of your tiles
    vec3 light_effect = background.rgb * (1.0 + (mask * brightness_multiplier));
    
    // 4. Output the result
    COLOR = vec4(light_effect, 1.0);
}