diff --git a/game/shaders/connection_cable.gdshader b/game/shaders/connection_cable.gdshader index 779baf6..04c39d9 100644 --- a/game/shaders/connection_cable.gdshader +++ b/game/shaders/connection_cable.gdshader @@ -5,19 +5,13 @@ uniform float glow_radius : hint_range(0.0, 1.0, 0.00001) = 1.0; uniform float travel_time : hint_range(0.0, 100.0, 1) = 5.0; float get_alpha(vec2 uv, float offset) { - float dist = fract(mod(TIME, travel_time)/travel_time + offset); - float left = uv.x - glow_radius; - float right = uv.x + glow_radius; - return step(left, dist) * (1.0 - step(right, dist)); + float progress = fract(mod(TIME, travel_time)/travel_time + offset); + return step(distance(progress, uv.x), glow_radius); } void fragment() { - float alpha = 0.0; - float offset = 0.0; - + COLOR.a = 0.0; for (float offset = 0.0; offset <= 1.0; offset += glow_interval) { - alpha += get_alpha(UV, offset); + COLOR.a += get_alpha(UV, offset); } - - COLOR.a = alpha; }