- Home /
Question by
unity_m8JWU6Gbrx70CQ · Dec 02, 2020 at 12:36 AM ·
shadersshadowstransparent
Shadow is rendered twice in differents transparent planes
Hi,
I'm using AR Foundation and I try to put a transparent material in ARPlane that receives shadows. I'm using this shader:
Shader "Custom/Shadows"
{
Properties
{
_ShadowIntensity("Shadow Intensity", Range(0, 1)) = 0.6
}
SubShader
{
Tags {"Queue" = "AlphaTest" }
Pass
{
Tags {"LightMode" = "ForwardBase" }
Cull Back
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fwdbase
#include "UnityCG.cginc"
#include "AutoLight.cginc"
uniform float _ShadowIntensity;
struct v2f
{
float4 pos : SV_POSITION;
LIGHTING_COORDS(0,1)
};
v2f vert(appdata_base v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
fixed4 frag(v2f i) : COLOR
{
float attenuation = LIGHT_ATTENUATION(i);
return fixed4(0,0,0,(1 - attenuation) * _ShadowIntensity);
}
ENDCG
}
}
Fallback "VertexLit"
}
It's work fine, but when I put 2 ARPlane in differents height, the shadow of an object higher then the top plane also is rendered in the bottom plane.
Is anyone have some idea of how to solve this?
Comment
Your answer
Follow this Question
Related Questions
Shader with shadows that can change alpha channel 0 Answers
Shadows don't appear through a custom shader 0 Answers
Adding shadows to custom shader 1 Answer
Lighting and shadows for LineRenderer 3 Answers
How can I prevent shadow sprite overlap? 0 Answers