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:

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
In which render pipelines does this happen?
– Pangaminiforward, deffered, any i think
– MihalinI was mistaken, now i've tested it. This backside shading is only appearing in forward lighting mode. I tried to use frame debugger, and i've noticed that standard shader draws shadow and backside shading in both forward and deffered modes at CollectShadows pass, but my test shader only draws backside shadow at forward mode
– MihalinIt seems like i figured it out. Still don't understand why, but if you write Tags { "Queue"="Transparent" } into SubShader node (not into Pass), only shadow will be rendered. The other solution is to set cube object's (in my case) rendertarget component's cast shadows option to "Shadows Only"
– MihalinIf you add Tags { "Queue" = "Transparent" "RenderType" = "Transparent" } and output a transparent color in your frag function, how does it behave? return fixed4(0.0, 0.0, 0.0, 0.0);
– Dray