Godot Version
v4.6
Question
Hi,
I’m trying to do a casual game where there are some cells which border is a line2D.
I would like to animate this line with a shader to achieve something near to following example:

But I cannot imagine how to achieve this effect.
Someone has any idea to program a shader with this behaviour?
Thanks!
Ok, solved.
shader_type canvas_item;
uniform vec4 line_color : source_color = vec4(0.0, 0.6, 1.0, 1.0);
uniform float speed : hint_range(0.0, 10.0) = 2.0;
uniform float tail_length : hint_range(0.0, 1.0) = 0.3; // Largo de la estela
uniform float glow_intensity : hint_range(1.0, 5.0) = 2.0;
void fragment() {
float time_cycle = fract(TIME * speed * 0.1);
float dist = fract(UV.x - time_cycle);
float mask = smoothstep(1.0 - tail_length, 1.0, dist);
vec4 final_color = line_color * mask * glow_intensity;
COLOR = vec4(final_color.rgb, mask * line_color.a);
}