TilingOffset.shader 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
  2. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  3. Shader "Hero/Unlit_TilingOffset"{
  4. Properties{
  5. _Color("Color",Color) = (1,1,1,1)
  6. _MainTex("Main Tex",2D) = "white"{}
  7. //_Cutoff("Alpha cutoff", Range(0,1)) = 0.5
  8. }
  9. SubShader{
  10. Pass{
  11. Tags{"Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent"}
  12. Blend SrcAlpha OneMinusSrcAlpha
  13. //Cull[_Cull] Lighting Off ZWrite Off
  14. CGPROGRAM
  15. #include "Lighting.cginc"
  16. #pragma vertex vert
  17. #pragma fragment frag
  18. fixed4 _Color;
  19. sampler2D _MainTex;
  20. float4 _MainTex_ST; //名字固定_MainTex+_ST
  21. //fixed _Cutoff;
  22. struct a2v {
  23. float4 vertex:POSITION;
  24. float3 normal:NORMAL;
  25. float4 textcoord:TEXCOORD0;
  26. };
  27. struct v2f {
  28. float4 svPos:SV_POSITION;
  29. float3 worldNormal:TEXCOORD0;
  30. float4 worldVertex:TEXCOORD1;
  31. float2 uv:TEXCOORD2;
  32. };
  33. v2f vert(a2v v) {
  34. v2f f;
  35. f.svPos = UnityObjectToClipPos(v.vertex);
  36. f.worldNormal = UnityObjectToWorldNormal(v.normal);
  37. f.worldVertex = mul(v.vertex, unity_WorldToObject);
  38. f.uv = v.textcoord.xy *_MainTex_ST.xy + _MainTex_ST.zw; //zw为偏移,+-设置旋转方向,xy为缩放
  39. return f;
  40. }
  41. fixed4 frag(v2f f) :SV_Target {
  42. fixed4 texColor = tex2D(_MainTex,f.uv.xy);
  43. fixed3 diffuse = texColor.rgb * _Color.rgb;
  44. return fixed4(diffuse, texColor.a);
  45. }
  46. ENDCG
  47. }
  48. }
  49. //FallBack "Specular"
  50. }