Inverting silhouette shader

I have a silhouette shader that flattens anything behind it. It works kind of like a pane of glass, so anything behind the glass is rendered as just a flat colour.

I’ve managed to get as far as this:

But it’s inverted! Here is my shader code:

Shader "Character Indicator"
{
    Properties
    {
        _Color ("Main Color", Color) = (1,1,1,1)
        _MainTex ("Base (RGB)", 2D) = "white" {}
        _Indicator ("Indicator Color", Color) = (1,1,1,1)
        _Cutoff ("Alpha cutoff", Range (0,1)) = 0.0
    }
  
    SubShader
    {
        Tags { "Queue" = "Geometry+1" "RenderType" = "Opaque" }
        CGPROGRAM
        #pragma surface surf BlinnPhong alphatest:_Cutoff
      
        uniform float4 _Color;
        uniform float4 _Indicator;
        uniform sampler2D _MainTex;
        
        struct Input
        {
            float2 uv_MainTex;
            float3 viewDir;
        };
      
        void surf (Input IN, inout SurfaceOutput o)
        {
            o.Albedo = tex2D ( _MainTex, IN.uv_MainTex).rgb * _Color;
        }
        ENDCG
       
        Pass
        {
            Tags { "LightMode" = "Always" }
            AlphaTest Greater [_Cutoff]
            ZWrite Off
            ZTest Greater
           
       
            SetTexture [_MainTex]
            {
                constantColor [_Indicator]
                //combine constant, texture
                combine constant* texture
            }
        }
    }
}

Is there a way I can reverse the way this shader is rendering?

Move a “2nd” pass above surface shader part and change ztest into less.

You mean like this? This just renders the plane out flat.

Shader "Character Indicator"
{
    Properties
    {
        _Color ("Main Color", Color) = (1,1,1,1)
        _MainTex ("Base (RGB)", 2D) = "white" {}
        _Indicator ("Indicator Color", Color) = (1,1,1,1)
        _Cutoff ("Alpha cutoff", Range (0,1)) = 0.0
    }
  
    SubShader
    {
        Pass
        {
            Tags { "LightMode" = "Always" }
            AlphaTest Greater [_Cutoff]
            ZWrite Off
            ZTest Less
           
            SetTexture [_MainTex]
            {
                constantColor [_Indicator]
                //combine constant, texture
                combine constant* texture
            }
        }

        Tags { "Queue" = "Geometry+1" "RenderType" = "Opaque" }
        CGPROGRAM
        #pragma surface surf BlinnPhong alphatest:_Cutoff
      
        uniform float4 _Color;
        uniform float4 _Indicator;
        uniform sampler2D _MainTex;
        
        struct Input
        {
            float2 uv_MainTex;
            float3 viewDir;
        };
      
        void surf (Input IN, inout SurfaceOutput o)
        {
            o.Albedo = tex2D ( _MainTex, IN.uv_MainTex).rgb * _Color;
        }
        ENDCG
       
       
    }
}

Sorry I mistaken. I will try find solution.

Ok I got it. I split shader into two part and use “UsePass”(lol) directive. But it’s strange, as far i remember, last time when I do something similar, I just write unlit part on top of subshader scope.

Shader "CharacterIndicatorLight"
{
    SubShader
    {
        Tags { "Queue" = "AlphaTest" "RenderType" = "TransparentCutout" }
               
        CGPROGRAM
        #pragma surface surf BlinnPhong
     
        uniform float4 _Color;
        uniform fixed _Cutoff;
        uniform float4 _Indicator;
        uniform sampler2D _MainTex;
       
        struct Input
        {
            float2 uv_MainTex;
            float3 viewDir;
        };
     
        void surf (Input IN, inout SurfaceOutput o)
        {
            fixed4 c=tex2D ( _MainTex, IN.uv_MainTex);
            o.Albedo = c.rgb * _Color;
            clip(c.a-_Cutoff);
        }
        ENDCG
       
    }
}
Shader "CharacterIndicator"
{
    Properties
    {
        _Color ("Main Color", Color) = (1,1,1,1)
        _MainTex ("Base (RGB)", 2D) = "white" {}
        _Indicator ("Indicator Color", Color) = (1,1,1,1)
        _Cutoff ("Alpha cutoff", Range (0,1)) = 0.0
    }

    SubShader
    {
        Tags { "Queue" = "AlphaTest" "RenderType" = "TransparentCutout" }
       
        UsePass "CharacterIndicatorLight/FORWARD"
           
        Pass
        {
            AlphaTest Greater [_Cutoff]
            ZWrite Off
            ZTest Greater
           
       
            SetTexture [_MainTex]
            {
                constantColor [_Indicator]
                //combine constant, texture
                combine constant* texture
            }
        }
    }
}

Hmm - appreciate your help, but I can’t seem to get this to work. Getting numerous errors but I think the main issue is that using multiple subshaders won’t work on mobile?

I builded and run it on Android- it’s works fine. What exactly errors say?