Focus circle / ring

Slap on a quad to display selection of a unit, etc. or simply draw a circle.

Shader code
shader_type spatial;
render_mode unshaded, cull_disabled, depth_draw_opaque;

uniform float size;
uniform float width;
uniform vec4 inner_color: hint_color;
uniform vec4 outer_color: hint_color;

void fragment() {
	ALPHA = 0.0;
	vec2 center = vec2(0.5);
	float d = distance(UV, center);
	float h = size * 0.5;
	float l = h - (width * 0.5);
	if (d <= h && d > l) {
		vec4 color = mix(inner_color, outer_color, smoothstep(l, h, d));
		ALPHA = color.a;
		ALBEDO = color.rgb;
circle, focus, indicator, 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 tcmug

Focus rectangle / box

Retro dither

Related shaders

Focus rectangle / box

Health circle

Simple circle transition


Inline Feedbacks
View all comments