Shader "LightMode" = "ShadowCaster" question

Hi people. I have this very simple code for unity’s shadow pass only

Shader "Test/TestShader"
{
	SubShader
	{
		Pass
		{
			Name "ShadowCaster"
			Tags { "LightMode" = "ShadowCaster" }
          
			Fog { Mode Off }
			ZWrite On ZTest Less Cull Off
			Offset 1, 1
			
			CGPROGRAM

			#pragma vertex vert
			#pragma fragment frag
			#pragma multi_compile_shadowcaster
			#pragma fragmentoption ARB_precision_hint_fastest
			
			#include "UnityCG.cginc"

			struct v2f
			{ 
				V2F_SHADOW_CASTER;
			};
          
			v2f vert(appdata_base v)
			{
				v2f o;
				TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
				return o;
			}
          
			float4 frag(v2f i) : COLOR
			{
				SHADOW_CASTER_FRAGMENT(i)
			}

			ENDCG
         }
     }
     FallBack Off
}

I’m trying to make invisible object with shadow, only using it’s shadow drawing pass (i need this for more complicated shader after i’ve done with this problem)
I don’t know how it may work in unity version before 5, but in unity 5 it additionaly shades back side of object itself. I mean object shades his back side and draws shadow on the background surface.

Here is what i have:

49609-shadows.png

So what i want to achieve is to get rid of this backside shading of the object (or whatever it is).

P.S. I know it can be done, because if in custom shader with no shadowcaster pass you’ll use fallback to legacy diffuse, object will be drawn invisible with shadow on the ground. But in my case i need to change shadowcaster code, therefore fallback doesn’t fit here.

Thanks in advance

Try ZWrite On ZTest LEqual Cull Front

Do this

Shader “Test/TestShader”
{
SubShader
{

         Name "ShadowCaster"
         Tags { "LightMode" = "ShadowCaster" }
       
         Fog { Mode Off }
         ZWrite On ZTest Less Cull Off
         Offset 1, 1
         
         CGPROGRAM

         #pragma vertex vert
         #pragma fragment frag
         #pragma multi_compile_shadowcaster
         #pragma fragmentoption ARB_precision_hint_fastest
         
         #include "UnityCG.cginc"

         struct v2f
         { 
             V2F_SHADOW_CASTER;
         };
       
         v2f vert(appdata_base v)
         {
             v2f o;
             TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
             return o;
         }
       
         float4 frag(v2f i) : COLOR
         {
             SHADOW_CASTER_FRAGMENT(i)
         }

         ENDCG
      
  }
    pass
{
Tags { "LightMode" = "ShadowCaster" }
}

}

you should use Transparent tag in your shader

Tags{ "Queue" = "Transparent" "LightMode" = "ShadowCaster" }

shader is here:

Shader "Test/TestShader"
{
	SubShader
	{
		Name "ShadowCaster"
		Tags{ "Queue" = "Transparent" "LightMode" = "ShadowCaster"  }
		Pass
	{


		CGPROGRAM

#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_shadowcaster
#pragma fragmentoption ARB_precision_hint_fastest

#include "UnityCG.cginc"

		struct v2f
	{
		V2F_SHADOW_CASTER;
	};

	v2f vert(appdata_base v)
	{
		v2f o;
		TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
			return o;
	}

	float4 frag(v2f i) : COLOR
	{
		SHADOW_CASTER_FRAGMENT(i)
	}

		ENDCG
	}
	}
		FallBack Off
}

also I answered this question here :
https://gamedev.stackexchange.com/questions/153523/how-can-i-fix-my-shadow-caster-problem/153524#153524