Advertisement
Guest User

ZWrite Sprite Shader

a guest
Jan 26th, 2015
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.03 KB | None | 0 0
  1. Shader "Custom/PowerSprite"
  2. {
  3. Properties
  4.     {
  5.         [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
  6.         AlphaCut ("Alpha Cutoff", Float) = .5
  7.     }
  8.  
  9.     SubShader
  10.     {
  11.         Tags
  12.         {
  13.             "Queue"="Transparent"
  14.             "IgnoreProjector"="True"
  15.             "RenderType"="TransparentCutout"
  16.             "PreviewType"="Plane"
  17. //          "CanUseSpriteAtlas"="True"
  18.         }
  19.        
  20.         ZWrite On
  21.         Cull Off
  22.         Blend One OneMinusSrcAlpha
  23.  
  24.         CGPROGRAM
  25.         #pragma surface surf Lambert vertex:vert alphatest:AlphaCut
  26.        
  27.         sampler2D _MainTex;
  28.         fixed AmbientResponse;
  29.         fixed4 _RecolorA;
  30.         fixed4 _RecolorB;
  31.  
  32.         struct Input
  33.         {
  34.             float2 uv_MainTex;
  35.             fixed4 color;
  36.         };
  37.        
  38.         void vert (inout appdata_full v, out Input o)
  39.         {
  40.             v.normal = float3(0,0,-1);
  41.             UNITY_INITIALIZE_OUTPUT(Input, o);
  42.             o.color = v.color;
  43.         }
  44.  
  45.         void surf (Input IN, inout SurfaceOutput o)
  46.         {
  47.             fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * IN.color;
  48.             o.Albedo = c.rgb * c.a;
  49.             if (c.a < 0.5)
  50.             {
  51.                 discard;
  52.             }
  53.             o.Alpha = c.a;
  54.         }
  55.        
  56.  
  57.         ENDCG
  58.     }
  59.  
  60.     Fallback Off
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement