DepthMask Shader - Receive Shadows

I have a simple DepthMask shader that masks any objects behind it. I would like the DepthMask shader to receive shadows as well. How is this possible?

Here is the shader:

Shader "Depth Mask" {
    SubShader {
        Tags {"Queue" = "Geometry-10" }
        Lighting Off
        ZTest LEqual
        ZWrite On
        ColorMask 0
        Pass {}
    }
}

For anyone interested, I managed to find a solution to this by combining two shaders from the forums. Here is the working shader:

Shader "FX/Matte Shadow Mask" {

Properties {
 _Color ("Main Color", Color) = (1,1,1,1)
 _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
 _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5

}


SubShader {

 Tags {"Queue" = "Geometry-10" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
 LOD 200
 Blend Zero SrcColor
 Lighting Off
 ZTest LEqual
 ZWrite On
 ColorMask 0
 Pass {}

CGPROGRAM
#pragma surface surf ShadowOnly alphatest:_Cutoff


fixed4 _Color;

struct Input {

 float2 uv_MainTex;

};

inline fixed4 LightingShadowOnly (SurfaceOutput s, fixed3 lightDir, fixed atten)

{
 fixed4 c;
 c.rgb = s.Albedo*atten;
 c.a = s.Alpha;
 return c;
}

void surf (Input IN, inout SurfaceOutput o) {
 fixed4 c = _Color;
 o.Albedo = c.rgb;
 o.Alpha = 1;
}
ENDCG
}
Fallback "Transparent/Cutout/VertexLit"
}

Hello,

Thank you for the provided shader. It works fine on windows, but on Android there is bad jitters on the shadows because of the alpha test.

I’ve tried a similar setup like in the picture below. There is an invisible plane under the robot object which is rendered in the depth maps only with ColorMask 0. Then, under the invisible plane there is another plane with a texture. It has the ReceiveShadows bool set to true.

It works fine on Windows, you can check the picture. But on Android the invisible plane’s depth is not written into the depth for some reason :(.

53047-final.png

Does anyone have an idea why the invisible plane doesn’t render on Android?