x


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 {}
    }
}
more ▼

asked Apr 22 '12 at 06:31 PM

absameen gravatar image

absameen
442 50 78 88

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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"
}
more ▼

answered Apr 22 '12 at 07:05 PM

absameen gravatar image

absameen
442 50 78 88

It works like a champ!!!! Thanks!

Mar 11 at 06:01 AM bktan81
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1740
x178
x13

asked: Apr 22 '12 at 06:31 PM

Seen: 1149 times

Last Updated: Mar 11 at 06:01 AM