Advertisement
Guest User

Shader_TrailUnity

a guest
Nov 23rd, 2016
111
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.13 KB | None
  1. Shader "FX/Trail"
  2. {
  3.     Properties
  4.     {
  5.         _TintColor("Tint Color", Color) = (0.500000,0.500000,0.500000,1)
  6.         _MainTex("GrayPackTexture", 2D) = "white" { }
  7.         _MaskTrail("MaskStretchTrail",2D) = "white" { }
  8.         _MaskBlockyFades("BlockyFadesTex",2D) = "white" { }
  9.         _ScrollSpeedX("X Scroll Speed", Range(0,10)) = 2
  10.         _TileU("Tiling U",Range(1,100)) = 1
  11.         _TileV("Tiling V",Range(1,100)) = 1
  12.     }
  13.         SubShader{
  14.         Tags
  15.     {
  16.         "RenderType" = "Transparent"
  17.         "queue" = "Transparent"
  18.         "IgnoreProjector" = "True"
  19.  
  20.     }
  21.         LOD 200
  22.         Cull Back
  23.  
  24.         CGPROGRAM
  25.         // Physically based Standard lighting model, and enable shadows on all light types
  26.         #pragma surface surf Standard alpha:fade
  27.  
  28.         // Use shader model 3.0 target, to get nicer looking lighting
  29.         #pragma target 3.0
  30.  
  31.  
  32.         sampler2D _MainTex;
  33.         sampler2D _MaskTrail;
  34.         sampler2D _MaskBlockyFades;
  35.  
  36.     struct Input {
  37.         float2 uv_MainTex;
  38.         float2 uv_MaskTrail;
  39.         float2 uv_MaskBlockyFades;
  40.     };
  41.  
  42.     fixed4 _TintColor;
  43.     fixed _ScrollSpeedX;
  44.     float _TileU;
  45.     float _TileV;
  46.     float ZeroToOne;
  47.  
  48.  
  49.     void surf(Input IN, inout SurfaceOutputStandard o) {
  50.         fixed2 scrolledUV = IN.uv_MaskTrail;
  51.         fixed2 tileUV = IN.uv_MaskTrail;
  52.  
  53.         fixed xScrollVal = (-_ScrollSpeedX) * _Time;
  54.         fixed yScrollVal = 0;
  55.        
  56.  
  57.         scrolledUV += fixed2(xScrollVal, yScrollVal);
  58.         tileUV *= fixed2(_TileU, _TileV);
  59.  
  60.         // Albedo comes from a texture tinted by color
  61.         float4 mask = tex2D(_MainTex, IN.uv_MaskTrail);
  62.         float4 movingMask = tex2D(_MaskTrail, scrolledUV);
  63.         float4 maskCube = tex2D(_MainTex, scrolledUV);
  64.  
  65.         float4 maskBlockyFades = tex2D(_MaskBlockyFades, scrolledUV);
  66.         float4 maskBlockyFadesMoving = tex2D(_MaskBlockyFades, tileUV);
  67.  
  68.         //masking of masks for emissive
  69.         if (maskBlockyFadesMoving.g >= maskBlockyFades.r)
  70.         {
  71.             ZeroToOne = 1;
  72.         }
  73.         else
  74.         {
  75.             ZeroToOne = 0;
  76.         }
  77.  
  78.  
  79.  
  80.         o.Albedo = (((1 - (1 - _TintColor)*(1 - movingMask))*0.75) - mask.r) * maskCube.b;//_TintColor * movingMask;
  81.         //(1-(1-_TintColor)*(1- movingMask)) = screen blend mode
  82.         o.Alpha = mask.g;
  83.         o.Emission = ((_TintColor *mask.r) + (_TintColor*ZeroToOne)); //_TintColor * mask.r ;
  84.     }
  85.     ENDCG
  86.     }
  87.         FallBack "Diffuse"
  88. }
Advertisement
RAW Paste Data Copied
Advertisement