daily pastebin goal
24%
SHARE
TWEET

Demo 42 - Varying color

tonynogo Jul 6th, 2017 816 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/VaryingColor"
  2. {
  3.     Properties
  4.     {
  5.         _MainTex ("Texture", 2D) = "white" {}
  6.         _RampTex ("Ramp texture", 2D) = "white" {}
  7.         _Speed ("Speed", Range(1, 10)) = 1
  8.     }
  9.     SubShader
  10.     {
  11.         Tags { "RenderType"="Opaque" }
  12.  
  13.         Pass
  14.         {
  15.             CGPROGRAM
  16.             #pragma vertex vert_img
  17.             #pragma fragment frag
  18.  
  19.             #include "UnityCG.cginc"
  20.            
  21.             sampler2D _MainTex;
  22.             sampler2D _RampTex;
  23.             float _Speed;
  24.  
  25.             fixed4 frag (v2f_img i) : SV_Target
  26.             {
  27.                 fixed4 col = tex2D(_MainTex, i.uv);
  28.                 return tex2D(_RampTex, fixed2(col.r + _Time.x * _Speed, 0.5));
  29.             }
  30.             ENDCG
  31.         }
  32.     }
  33. }
RAW Paste Data
Top