- Home /
point light illuminates makes transparent object visible
Hello, i'm trying to implement shadows in a 2d game with an orthographic camera, so i did the following: 1) create a transparent sphere under each character's sprite 2) use directional light to cast shadows on the sphere (so the sphere is not visible, and it looks like the sprite is casting the shadow)
this works well (See figure without point light) but when i add a point light to my scene, the spheres become visible again.
does anyone know what i can do to stop the spheres from re-appearing when i use a point light? maybe some modifications to my shader (below)?
thanks!
Shader "Custom/Transparent Shadow Receiver" {
Properties{
}
SubShader{
Tags {"Queue" = "AlphaTest" "IgnoreProjector" = "True" "RenderType" = "TransparentCutout"}
LOD 200
ZWrite Off
Blend Zero SrcColor
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) {
o.Albedo = 1;
o.Alpha = 1;
}
ENDCG
}
Fallback "Transparent/Cutout/VertexLit"
}
Your answer
Follow this Question
Related Questions
Problem with shadow casting on transparent material 0 Answers
Unity Mesh Based Shadows Overlap Issue 0 Answers
Masking sprite with another sprite? 0 Answers
Transparent/Specular Shader - I want alpha to control spec, not transparency 1 Answer
get UV coordinates on world position in fragment shader 0 Answers