How to render a radius?

I want to render an action radius like this spell radius from dota: Dota 2 Tip of the Day - Range Display/Indicator ● #004 TofD - YouTube

I’ve successfully set up a selection indicator for my units using a projector. But this works only for small circles. I’ve I use the same mechanism for the action radius by increasing the orthographic size the texture is scaled up and by this reason the selection circle and radius circle does not have the same thickness.

How could I realize such an effect like dota?


Shader “Custom/Radius Shader” {
Properties {
_Color (“Color”, Color) = (1,1,1,1)
_Radius (“Radius”, Float) = 1
_Mid (“Midpoint”, Vector) = (0,0,0,0)
_Width (“Width”, Range(0,1)) = 0.1
SubShader {
Tags { “RenderType”=“Transparent” “Queue”=“Transparent” }
LOD 200

		Pass {
			Blend SrcAlpha OneMinusSrcAlpha
			ZWrite Off
			ZTest Always

			#pragma vertex vert
			#pragma fragment frag
			#include "UnityCG.cginc"

			struct v2f {
				float4 pos : SV_POSITION;
				float3 objPos : TEXCOORD0;

			v2f vert (appdata_base v) {
				v2f o;
				o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
				o.objPos = v.vertex;
				return o;

			half _Radius;
			float3 _Mid;
			half _Width;
			fixed4 _Color;

			half4 frag (v2f i) : SV_Target
				half circle = pow (i.objPos.x - _Mid.x, 2) + pow (i.objPos.y - _Mid.y, 2) + pow (i.objPos.z - _Mid.z, 2);
				if (circle <= pow (_Radius, 2) && circle >= pow (_Radius - _Width, 2))
					return _Color;
					return half4 (0,0,0,0);
	FallBack "Diffuse"

Attach this to a quad and it should render a radius. I’m not sure which element of the video in particular you want, but this should work.

Note It will render on top of everything else, which can be changed by the ZTesting.