- Home /
Particle Cutout that cast shadow ?
What shader is required to cast shadows with particle cutout (in 3.x)?
Here is the shader I use :
Shader "Particles/Cutout" { Properties { _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5) _MainTex ("Particle Texture", 2D) = "white" }
SubShader { Tags { "Queue" = "Transparent" } Cull Off Lighting Off ZWrite On //Fog { color (0,0,0,0) } AlphaTest Greater .5 ColorMask RGB BindChannels { Bind "Color", color Bind "Vertex", vertex Bind "TexCoord", texcoord } Pass { SetTexture [_MainTex] { constantColor [_TintColor] combine constant primary DOUBLE } SetTexture [_MainTex] { combine previous texture } } } }
Answer by AR_Rizvi · Aug 26, 2013 at 01:02 PM
This Shader is transparent and transparent object cant cast shadows in unity try making this shader and cutout shader it can casta nd recive shadows
try sumthing like this
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="Transparentcutout"}
pragma surface surf Lambert alphatest:_Cutoff
and it should work i hope it helps :)
Answer by Jona-Marklund · Aug 26, 2013 at 07:51 PM
If you don't want to turn the shader into a surface shader, you could add another pass which takes care of the shadow casting, like so.
Shader "JM/CutoffShadowCast" {
Properties {
_Cutoff ("Outline Thickness", Range(0.0,1.0)) = 0.5
_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)
_MainTex ("Particle Texture", 2D) = "white"
}
SubShader {
Cull Off
Lighting Off
ZWrite On
//Fog { color (0,0,0,0) }
AlphaTest Greater [_Cutoff]
ColorMask RGB
BindChannels {
Bind "Color", color
Bind "Vertex", vertex
Bind "TexCoord", texcoord
}
Pass{
Tags { "LightMode" = "ShadowCaster" }
SetTexture [_MainTex]
}
Pass {
Tags { "Queue" = "AlphaTest" "RenderType"="Transparentcutout" }
SetTexture [_MainTex] {
constantColor [_TintColor]
combine constant * primary DOUBLE
}
SetTexture [_MainTex] {
combine previous * texture
}
}
}
Fallback "VertexLit"
}
Best Regards
Your answer
Follow this Question
Related Questions
(SOLVED) How to bake lightmaps with transparent cutout shader ? 2 Answers
Shader: Cutout behavior mixed with masking behavior 0 Answers
Can I turn off realtime shadows and use a shader to cast realtime shadows? 0 Answers
Is there any double sided shadow casting transparent cutout shader? 3 Answers
Unity Custom CutOut Shader 1 Answer