Simple horizontal radar scan with blip trace

To use this shader add it to a TextureRect that has a texture. As there are no array uniforms in gdshader i had to add positions manually one by one. Just repeat the code for each position.

Shader code
shader_type canvas_item;

uniform vec4 background_color: hint_color;
uniform float scan_line_width: hint_range(0.0, 0.5, 0.01);

uniform vec2 position_1;
uniform vec2 position_2;
uniform vec2 position_3;
uniform vec2 position_4;
uniform vec2 position_5;
uniform vec2 position_6;

void fragment() {
	COLOR = vec4(background_color.rgb, 0.8);
	
	float scan_front_pos = fract(TIME / 5.0);
	float scan_back_pos = scan_front_pos - scan_line_width;
	
	if (length(UV - position_1) < 0.02) {
		COLOR *= fract(position_1.x - scan_front_pos) + 1.0;
	}
	
	if (length(UV - position_2) < 0.02) {
		COLOR *= fract(position_2.x - scan_front_pos) + 1.0;
	}
	
		if (length(UV - position_3) < 0.02) {
		COLOR *= fract(position_3.x - scan_front_pos) + 1.0;
	}
	
	if (UV.x > scan_back_pos && UV.x <= scan_front_pos) {
		float ratio = (UV.x - scan_back_pos) / scan_line_width + 1.0;
		COLOR = vec4(COLOR.xyz * ratio, COLOR.a);
	}
}
Tags
blip, radar, trace
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

Radar with trace blip

Radar Blip

Radar Blip Ring

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments