Advertisement
tonynogo

Demo 05 - Scrolling texture

Jul 6th, 2017
5,753
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/ScrollingUV" {
  2.     Properties {
  3.         _MainTex ("Base (RGB)", 2D) = "white" {}
  4.         _TextureColor ("Texture Color", Color) = (1, 1, 1, 1)
  5.         _ScrollXSpeed ("X Scroll Speed", Range(-5, 5)) = 0
  6.         _ScrollYSpeed ("Y Scroll Speed", Range(-5, 5)) = 0
  7.     }
  8.     SubShader {
  9.         Tags { "RenderType"="Opaque" }
  10.        
  11.         CGPROGRAM
  12.         #pragma surface surf Lambert alpha
  13.  
  14.         sampler2D _MainTex;
  15.         fixed4 _TextureColor;
  16.         fixed _ScrollXSpeed;
  17.         fixed _ScrollYSpeed;
  18.  
  19.         struct Input {
  20.             float2 uv_MainTex;
  21.         };
  22.  
  23.         void surf (Input IN, inout SurfaceOutput o) {
  24.             fixed varX = _ScrollXSpeed * _Time;
  25.             fixed varY = _ScrollYSpeed * _Time;
  26.             fixed2 uv_Tex = IN.uv_MainTex + fixed2(varX, varY);
  27.             half4 c = tex2D(_MainTex, uv_Tex) * _TextureColor;
  28.             o.Albedo = c.rgb;
  29.             o.Alpha = c.a;
  30.         }
  31.         ENDCG
  32.     }
  33.     FallBack "Diffuse"
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement