Shader "Custom/SingleShadow" {
Properties {
_MainTint ("Color", Color) = (1, 1, 1, 1)
_LightDirection ("LightDirection", Vector) = (1, 1, 1, 1)
_ShodowIntensity ("ShodowIntensity", float) = 1
}
// real shadow
SubShader {
Tags { "Queue"="Transparent" "RenderType"="Shadow" "IgnoreProjector"="True" }
Pass {
Lighting Off
Cull Back
ZTest LEqual
ZWrite Off
Offset -2, -2
Blend SrcAlpha OneMinusSrcAlpha
Stencil {
Ref 64
Comp Greater
Pass Replace
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
fixed4 _MainTint;
fixed4 _LightDirection;
fixed _ShodowIntensity;
struct v2f {
half4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
};
v2f vert (appdata_base v)
{
v2f o;
half4 worldPos = mul(unity_ObjectToWorld, v.vertex);
worldPos.xyz = float3(worldPos.x - worldPos.y / _LightDirection.y * _LightDirection.x, 0, worldPos.z - worldPos.y / _LightDirection.y * _LightDirection.z);
v.vertex = mul(unity_WorldToObject, worldPos);
o.pos = UnityObjectToClipPos(v.vertex);
return o;
}
fixed4 frag (v2f i) : COLOR
{
fixed4 outp = _MainTint;
outp.a = _ShodowIntensity;
return outp;
}
ENDCG
}
}
}