I'm trying to make invisible object with shadow by using it's shadow castting pass it additionaly shades back side of object itself. I mean object shades his back side and draws shadow on the background surface.(my unity version is Unity 5.6)

you can see this problem in below animated gif:

shadow caster problem

this is my shader for unity's shadow pass:

Shader "Test/ShadowCaster"
    Tags{ "LightMode" = "ShadowCaster"  }
    Name "ShadowCaster"

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

#include "UnityCG.cginc"

        struct v2f

    v2f vert(appdata_base v)
        v2f o;
        return o;

    float4 frag(v2f i) : COLOR
        FallBack Off
  • 2
    \$\begingroup\$ You can do this without a special shader by setting the object's renderer mode to Shadows Only. \$\endgroup\$ – DMGregory Jan 24 '18 at 6:10
  • \$\begingroup\$ @DMGregory that's right but I had problem In my shader that it only fixed by using shadow caster in shader.in vertex and fragment shader you can't do it so I have to write it from scratch. \$\endgroup\$ – Seyed Morteza Kamali Jan 24 '18 at 11:03

I solved this problem by adding Transparent Queue tag to my shader.

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


Transparent - this render queue is rendered after Geometry and AlphaTest, in back-to-front order. Anything alpha-blended (i.e. shaders that don’t write to depth buffer) should go here (glass, particle effects).


Useful link for learning shadow casters in unity.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.