Last active
October 17, 2016 02:01
-
-
Save x5lcfd/145d1c860fb24ed0220b84ebdf9482e6 to your computer and use it in GitHub Desktop.
SpriteShadows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Sprites/SpriteShadows" | |
{ | |
Properties | |
{ | |
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {} | |
_Color ("Tint", Color) = (1,1,1,1) | |
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.5 | |
_Intensity("Shadow Intensity", Range(0,1)) = 0.5 | |
} | |
SubShader | |
{ | |
Tags | |
{ | |
"Queue"="AlphaTest" | |
"IgnoreProjector"="True" | |
"RenderType"="TransparentCutout" | |
"PreviewType"="Plane" | |
"CanUseSpriteAtlas"="True" | |
} | |
LOD 200 | |
Cull Off | |
Lighting On | |
ZWrite Off | |
CGPROGRAM | |
#pragma surface surf ShadowLambert addshadow alphatest:_Cutoff | |
#include "Lighting.cginc" | |
sampler2D _MainTex; | |
fixed4 _Color; | |
float _Intensity; | |
struct Input | |
{ | |
float2 uv_MainTex; | |
}; | |
half4 LightingShadowLambert (SurfaceOutput s, half3 lightDir, half atten) | |
{ | |
half NdotL = dot (s.Normal, lightDir); | |
half4 c; | |
atten = (NdotL * atten) - _Intensity; | |
if ( atten <= 0 ) | |
{ | |
c.rgb = s.Emission * atten * _LightColor0.a ; | |
} | |
else | |
{ | |
c.rgb = 0; | |
} | |
c.a = s.Alpha; | |
return c; | |
} | |
void surf (Input IN, inout SurfaceOutput o) | |
{ | |
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; | |
o.Alpha = c.a; | |
o.Emission = c.rgb; | |
} | |
ENDCG | |
} | |
Fallback "Legacy Shaders/Transparent/Cutout/VertexLit" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment