Circle Rect

Shader code
shader_type spatial;

uniform float radius = 0.4; // rayon en UV space (0..0.5)
uniform float border_width = 0.02;
uniform float dash_length = 0.1;
uniform float dash_gap = 0.05;
uniform float speed = 1.0;
uniform vec4 border_color:source_color = vec4(1.0, 1.0, 1.0, 1.0);

void fragment() {
    vec2 center = vec2(0.5, 0.5);
    vec2 uv = UV - center;
    float dist = length(uv);

    float angle = atan(uv.y, uv.x); // -PI..PI
    angle = (angle + 3.141592) / (2.0 * 3.141592); // 0..1

    angle = fract(angle + TIME * speed);

    float dash_cycle = dash_length + dash_gap;
    float pattern_pos = mod(angle, dash_cycle);

    float edge = abs(dist - radius);

    if (edge < border_width) {
        if (pattern_pos < dash_length) {
            ALBEDO = border_color.rgb;
            ALPHA = border_color.a;
        } else {
            discard;
        }
    } else {
        discard;
    }
}
Tags
line, round, selection
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.

More from LeChatonMortel_

Selection Box

Related shaders

Focus circle / ring

“Unit Selected” Oscillating Circle

Circle Mask (with Feathering & Position)

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments