Unity 5 - set shadowCastingMode to shadow only and 2 sided?

Is there a way to set the renderer shadowCastingMode to be both ShadowOnly and TwoSided? It would be useful for us.

Wishing I knew the same thing. This is the top result on Google for this question. Bump.

This is a good solution when combined with the TwoSided shadow setting:

Cheers,
Pete

As this is still the top result for a search about “unity shadow only 2 sided” (and the only pertaining result for the matter), and Unity 2019.4 still doesn’t offer a “2-sided shadow only” option, here my own shader to handle this situation :

Shader "TOO/Nothing"        // Render nothing but still casts shadows
{
    Properties
    {
    }

    SubShader
    {
        Tags { "RenderType" = "Opaque" }
        LOD 200

        ColorMask 0
        ZWrite Off

        CGPROGRAM
        // Physically based Standard lighting model, and enable shadows on all light types
        //#pragma surface surf Lambert fullforwardshadows nolightmap
        #pragma surface surf Nothing fullforwardshadows nolightmap        // Use "Nothing" lighting model instead of "Lambert" to save on shader processing

        struct Input
        {
            half Dummy; // Just a dummy because surf expects something
        };

        half4 LightingNothing(SurfaceOutput s, UnityGI gi)
        {
            return half4(0, 0, 0, 0);
        }

        half4 LightingNothing_Deferred(SurfaceOutput s, UnityGI gi, out half4 outDiffuseOcclusion, out half4 outSpecSmoothness, out half4 outNormal)
        {
            outDiffuseOcclusion = outSpecSmoothness = outNormal = half4(0, 0, 0, 0);
            return half4(0, 0, 0, 0);
        }

        void LightingNothing_GI(
            SurfaceOutput s,
            UnityGIInput data,
            inout UnityGI gi)
        {
            //gi = UnityGlobalIllumination(data, 1.0, s.Normal);
        }

        // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
        // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
        // #pragma instancing_options assumeuniformscaling
        UNITY_INSTANCING_BUFFER_START(Props)
        // put more per-instance properties here
        UNITY_INSTANCING_BUFFER_END(Props)

        void surf(Input IN, inout SurfaceOutput o)
        {
        }

        ENDCG
    }
    FallBack "Diffuse"
}

The alpha-based shader linked in the previous post doesn’t use Alpha Test, so I guess its performance isn’t that great.

Here I used a classic opaque shader where I disabled the writing to both the RGB channels (with “ColorMask 0”) and the depth buffer (with “ZWrite Off”), as well as writing a custom lighting model that does nothing, which should save on shader processing. :slight_smile: