Geometry Intersection Shader

I have seen innumerable examples on how to perform this, yet none of them work anymore, or they only allow one instance of this intersection to appear.

I would like to recreate the intersection shader from The Divison, as seen here

Characters and world geometry alike are highlighted inside a sphere.
As well, the intensity of the highlight is a gradient, where in the center it is less intense, and on the edges, it is most intense.

How can I start this? Will I need to render a sphere several times and use the stencil buffer?

This shader “colors” an area inside a “rendered” mesh: for you case, simply create a material with it, and apply it to a sphere (or whatever) placed appropriately in worldspace. It DOES lack the gradient you mentioned, but it’s a start. (the sample picture uses 2 concentric spheres with different materials, both using this shader)

Shader "Unlit/highlightVolume"
{
	Properties
	{
		_Color("Color", Color) = (1,1,1,.2) 
	}
	SubShader
	{
		Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
		Pass
		{
			Stencil
			{
				Ref 172
				Comp Always
				Pass Replace
				ZFail Zero
			}
			Blend Zero One
			Cull Front
			ZTest  GEqual
			ZWrite Off

		}// end stencil pass
		Pass
		{
			Blend SrcAlpha OneMinusSrcAlpha
			Stencil
			{
				Ref 172
				Comp Equal
			}
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			float4 _Color;
			struct appdata
			{
				float4 vertex : POSITION;
			};
			struct v2f
			{
				float4 vertex : SV_POSITION;
			};
			v2f vert(appdata v)
			{
				v2f o;
				o.vertex = UnityObjectToClipPos(v.vertex);
				return o;
			}
			fixed4 frag(v2f i) : SV_Target
			{
				return _Color;
			}
			ENDCG
		}//end color pass
	}
}

114071-volume-shader.png

Well, since you want the sphere highlighting to not be visible behind the car in the front you have to use the stencil buffer. A common implementation could be done by useng a two pass stencil shader. The first pass would render just the front faces of the sphere (cull back) and set the stencil value on pass. The second pass would only render the backfaces of the sphere (cull front) and do a stencil compare to only pass if the stencil value is “1”. The important part of the second pass is that you now only draw when the ztest fails (ztest greater). That means when the backfaces are actually behind something else. The second pass would use alpha blending to render those backfaces. Note that you would need to do the fading based on the distance of each fragment from the center of the sphere.

Note that this technique may give you problems when your camera would “enter” the sphere area. If you want / need to support this case you basically have to implement the usual depth fail stencil shadows. It works similar to this one but instead of actual rendering the sphere we only increment / decrement the stencil value. You would need a thrid pass to actually rendering the sphere visually.