Shader——通过修改UV坐标实现纹理贴图的滚动

作者:追风剑情 发布于:2015-9-5 12:05 分类:Shader

  1. Shader "Custom/UVMove" {
  2. Properties {
  3. _MainTint ("Diffuse Tint", Color) = (1,1,1,1)
  4. _MainTex ("Base (RGB)", 2D) = "white" {}
  5. _ScrollXSpeed ("X Scroll Speed", Range(0, 10)) = 2
  6. _ScrollYSpeed ("Y Scroll Speed", Range(0, 10)) = 2
  7. }
  8. SubShader {
  9. Tags { "RenderType"="Opaque" }
  10. LOD 200
  11. CGPROGRAM
  12. #pragma surface surf Lambert
  13.  
  14. sampler2D _MainTex;
  15. fixed4 _MainTint;
  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. fixed2 scrolledUV = IN.uv_MainTex;
  25. fixed xScrollValue = _ScrollXSpeed * _Time;
  26. fixed yScrollValue = _ScrollYSpeed * _Time;
  27. scrolledUV += fixed2(xScrollValue, yScrollValue);
  28. half4 c = tex2D (_MainTex, scrolledUV);
  29. o.Albedo = c.rgb * _MainTint;
  30. o.Alpha = c.a;
  31. }
  32. ENDCG
  33. }
  34. FallBack "Diffuse"
  35. }

运行效果


u2222222222222.png


uuuuuuuuuuuuuu.png

标签: Shader

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号