Advertisement
SayAllenthing

Sprite Shadow Shader

Sep 26th, 2020
13,104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Sprite Shadow Shader - AllenDevs
  2.  
  3. Shader "Sprites/Custom/SpriteShadow"
  4. {
  5.     Properties
  6.     {
  7.         [PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
  8.     _Color("Tint", Color) = (1,1,1,1)
  9.         [MaterialToggle] PixelSnap("Pixel snap", Float) = 0
  10.         [HideInInspector] _RendererColor("RendererColor", Color) = (1,1,1,1)
  11.         [HideInInspector] _Flip("Flip", Vector) = (1,1,1,1)
  12.         [PerRendererData] _AlphaTex("External Alpha", 2D) = "white" {}
  13.     [PerRendererData] _EnableExternalAlpha("Enable External Alpha", Float) = 0
  14.         _Cutoff("Alpha Cutoff", Range(0,1)) = 0.5
  15.     }
  16.  
  17.         SubShader
  18.     {
  19.         Tags
  20.     {
  21.         "Queue" = "Transparent"
  22.         "IgnoreProjector" = "True"
  23.         "RenderType" = "Transparent"
  24.         "PreviewType" = "Plane"
  25.         "CanUseSpriteAtlas" = "True"
  26.     }
  27.  
  28.         Cull Off
  29.         Lighting Off
  30.         ZWrite Off
  31.         Blend One OneMinusSrcAlpha
  32.  
  33.         CGPROGRAM
  34. #pragma surface surf Lambert vertex:vert alphatest:_Cutoff addshadow nofog nolightmap nodynlightmap keepalpha noinstancing
  35. #pragma multi_compile_local _ PIXELSNAP_ON
  36. #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
  37. #include "UnitySprites.cginc"
  38.  
  39.         struct Input
  40.     {
  41.         float2 uv_MainTex;
  42.         fixed4 color;
  43.     };
  44.  
  45.     void vert(inout appdata_full v, out Input o)
  46.     {
  47.         v.vertex = UnityFlipSprite(v.vertex, _Flip);
  48.  
  49. #if defined(PIXELSNAP_ON)
  50.         v.vertex = UnityPixelSnap(v.vertex);
  51. #endif
  52.  
  53.         UNITY_INITIALIZE_OUTPUT(Input, o);
  54.         o.color = v.color * _Color * _RendererColor;
  55.     }
  56.  
  57.     void surf(Input IN, inout SurfaceOutput o)
  58.     {
  59.         fixed4 c = SampleSpriteTexture(IN.uv_MainTex) * IN.color;
  60.         o.Albedo = c.rgb * c.a;
  61.         o.Alpha = c.a;
  62.     }
  63.     ENDCG
  64.     }
  65.  
  66.         Fallback "Transparent/VertexLit"
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement