XGame-TestCloud.shader 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
  2. // "Legacy Shaders/Transparent/Diffuse"
  3. Shader "XGame/TestCloud"
  4. {
  5. Properties
  6. {
  7. _Color ("Main Color", Color) = (1,1,1,1)
  8. _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
  9. _ScrollY ("Scroll Speed", Range(0, 1)) = 1
  10. }
  11. SubShader
  12. {
  13. Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
  14. LOD 200
  15. CGPROGRAM
  16. #pragma surface surf NoLight alpha:fade noforwardadd
  17. sampler2D _MainTex;
  18. fixed4 _Color;
  19. float _ScrollY;
  20. struct Input
  21. {
  22. float2 uv_MainTex;
  23. };
  24. float2 ModuloUV(float2 uv)
  25. { // 取模运算,返回小数部分
  26. // uv.y -= floor(uv.y);
  27. return uv - floor(uv);
  28. // return frac(uv);
  29. }
  30. void surf (Input IN, inout SurfaceOutput o)
  31. {
  32. fixed4 c = tex2D(_MainTex, ModuloUV(IN.uv_MainTex + float2(0, _ScrollY * _Time.y))) * _Color;
  33. o.Albedo = c.rgb;
  34. o.Alpha = c.a;
  35. }
  36. //光照方程,名字为Lighting接#pragma suface后的光照方程名称
  37. //lightDir :顶点到光源的单位向量
  38. //viewDir :顶点到摄像机的单位向量
  39. //atten :关照的衰减系数
  40. float4 LightingNoLight(SurfaceOutput s, float3 lightDir,half3 viewDir, half atten)
  41. {
  42. float4 c ;
  43. c.rgb = s.Albedo;
  44. c.a = s.Alpha;
  45. return c;
  46. }
  47. ENDCG
  48. }
  49. Fallback "Unlit/Transparent"
  50. }