- Home /
Shader Depth Mask - Shadows with cutouts
I use the below code to cutout a shape in my object and cast shadows. But it cast the shadow from the original object, but i would like it to cutout on the shadows aswell. Anyone have any ideas? Thanks :)
Shader "Depth Cutout" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.1
}
SubShader {
Tags {"RenderType"="TransparentCutoff"}
LOD 200
Blend Zero SrcColor
Lighting Off
ZTest LEqual
ZWrite On
ColorMask 0
Pass {
}
CGPROGRAM
#pragma surface surf ShadowOnly alphatest:_Cutoff
uniform float temp;
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) {
if (temp == 1)
{
fixed4 c = _Color;
o.Albedo = c.rgb;
o.Alpha = 1;
}
}
ENDCG
}
Fallback "Transparent/Cutout/VertexLit"
}
Answer by Namey5 · Jun 15, 2016 at 09:49 PM
You have to add "addshadow" to the surface declaration.
Performance was too poor for this method so replacing the objects with actual objects pre cut was required. But thanks for the answer.
Answer by t-pedrob · Jun 15, 2016 at 07:05 PM
Hi, I'm with the same problem, have you found a solution to this problem yet?
Thank your for your time
Your answer
Follow this Question
Related Questions
Geometry Shader not writing to depth texture 0 Answers
Cut out shader with geometry depth and alpha 0 Answers
How do I achieve this effect? 2 Answers
No shadows when looking through a cutout shader 2 Answers
Render scene depth to a texture 4 Answers