_Dickie

Alpha Erode Particle Shader Unity

Sep 13th, 2017
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.14 KB | None | 0 0
  1. Shader "Maki/Particle/AlphaErode"
  2. {
  3.     Properties
  4.     {
  5.         _MainTex ("Texture", 2D) = "white" {}
  6.         _AlphaScale("Alpha Scale", float) = 1
  7.         _MainColor("Main Color", color) = (1,1,1,1)
  8.     }
  9.     SubShader
  10.     {
  11.         Tags {
  12.             "IgnoreProjector"="True"
  13.             "Queue"="Transparent"
  14.             "RenderType"="Transparent"
  15.         }
  16.  
  17.         Pass
  18.         {
  19.             zwrite off
  20.  
  21.             CGPROGRAM
  22.             #pragma vertex vert
  23.             #pragma fragment frag
  24.  
  25.            
  26.             #include "UnityCG.cginc"
  27.  
  28.             struct appdata
  29.             {
  30.                 float4 vertex : POSITION;
  31.                 float2 uv : TEXCOORD0;
  32.                 float4 color : COLOR;
  33.             };
  34.  
  35.             struct v2f
  36.             {
  37.                 float2 uv : TEXCOORD0;
  38.                 float4 color : COLOR;
  39.                 float4 vertex : SV_POSITION;
  40.             };
  41.  
  42.             sampler2D _MainTex;
  43.            
  44.             v2f vert (appdata v)
  45.             {
  46.                 v2f o;
  47.                 o.vertex = UnityObjectToClipPos(v.vertex);
  48.                 o.uv = v.uv;
  49.                 o.color = v.color;
  50.                 o.color.a = 1 - o.color.a;
  51.  
  52.                 return o;
  53.             }
  54.  
  55.             float _AlphaScale;
  56.             half4 _MainColor;
  57.  
  58.             fixed4 frag (v2f i) : SV_Target
  59.             {
  60.                 fixed col = tex2D(_MainTex, i.uv * _AlphaScale);
  61.                 clip(col - i.color.a);
  62.                 return _MainColor * i.color;
  63.  
  64.             }
  65.             ENDCG
  66.         }
  67.     }
  68. }
Add Comment
Please, Sign In to add comment