shader_type canvas_item; uniform sampler2D trail_texture; uniform float decay_factor; void fragment() { vec3 orig = texture(trail_texture, UV).rgb; float trail = orig.r; float sum = 0.0; for(float i=-1.0;i<=1.5;i++) { for(float j=-1.0;j<=1.5;j++) { vec2 offset = vec2(i,j); sum += texture(trail_texture, UV + vec2(i,j)).g; } } trail = sum / 9.0; trail = trail * decay_factor; COLOR = vec4(trail, orig.g, orig.b, 1.0); }