shader_type canvas_item;

uniform vec4 blink_color: source_color;
uniform float blink_intensity = 0.0;
uniform float teleport_progress = 0.0; // 0 = fully visible, 1 = fully gone
uniform float scanline_density = 50.0; // Controls the number of scanlines

void fragment() {
    vec4 color = texture(TEXTURE, UV);
    color = mix(color, blink_color, blink_intensity * color.a);

    // Generate scanline effect based on teleport_progress
    float scanline = mod(UV.y * scanline_density, 1.0); // Creates scanline pattern
    float cutoff = smoothstep(0.0, 1.0, UV.y - teleport_progress); // Controls disappearance

    // Mix scanline effect with cutoff to make it gradually disappear
    float alpha_multiplier = step(scanline, cutoff);
    color.a *= alpha_multiplier;

    COLOR = color;
}