shader_type canvas_item; uniform vec4 color = vec4(1.0f, 1.0f, 1.0f, 1.0f); uniform float thickness = 0.1f; uniform float rotation_speed = 1.0f; vec2 rotate(vec2 v, float angle) { return vec2( v.x * cos(angle) + v.y * sin(angle), v.x * sin(angle) - v.y * cos(angle) ); } void fragment() { float distance_from_centre = distance(vec2(0.5f, 0.5f), UV.xy) * 2.0f; float inner_circle = smoothstep((1.0f - (SCREEN_PIXEL_SIZE.x * 96.0f)) - thickness, 1.0f - thickness, distance_from_centre); float outer_circle = 1.0f - smoothstep((1.0f - (SCREEN_PIXEL_SIZE.x * 96.0f)), 1.0f, distance_from_centre); float throbber_edge = outer_circle * inner_circle; vec2 relative = rotate(UV - vec2(0.5f, 0.5f), TIME * rotation_speed); float angle = atan(relative.x, relative.y); float t = (angle + PI) / 2.0f / PI; COLOR *= throbber_edge * mix(vec4(color.rgb, 0.0f), vec4(color.rgb, 1.0f), t); }