XGame-TestTime.shader 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. Shader "XGame/TestTime"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. _ScrollY ("Scroll Speed", Range(0, 1)) = 1
  7. _MoveTime("Move Time", float) = 0
  8. }
  9. SubShader
  10. {
  11. Tags { "RenderType"="Opaque" }
  12. LOD 100
  13. Pass
  14. {
  15. CGPROGRAM
  16. #pragma vertex vert
  17. #pragma fragment frag
  18. // make fog work
  19. // #pragma multi_compile_fog
  20. #include "UnityCG.cginc"
  21. struct appdata
  22. {
  23. float4 vertex : POSITION;
  24. float2 uv : TEXCOORD0;
  25. };
  26. struct v2f
  27. {
  28. float2 uv : TEXCOORD0;
  29. float4 vertex : POSITION;
  30. };
  31. sampler2D _MainTex;
  32. float4 _MainTex_ST;
  33. float _ScrollY;
  34. float _MoveTime;
  35. float2 ModuloUV(float2 uv)
  36. { // È¡Ä£ÔËËã,·µ»ØСÊý²¿·Ö
  37. // uv.y -= floor(uv.y);
  38. return uv - floor(uv);
  39. // return frac(uv);
  40. }
  41. v2f vert (appdata v)
  42. {
  43. v2f o;
  44. // v.vertex.y = sin(v.vertex.x+_Time.y);
  45. o.vertex = UnityObjectToClipPos(v.vertex);
  46. o.uv = v.uv + float2(0, _ScrollY * _MoveTime);
  47. return o;
  48. }
  49. fixed4 frag (v2f i) : SV_Target
  50. {
  51. fixed4 col = tex2D(_MainTex, ModuloUV(i.uv));
  52. return col;
  53. }
  54. ENDCG
  55. }
  56. }
  57. }