UIDefaultCurved.shader 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. Shader "CompassNavigatorPro/UI Default Curved"
  2. {
  3. Properties
  4. {
  5. [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
  6. _Color ("Tint", Color) = (1,1,1,1)
  7. _StencilComp ("Stencil Comparison", Float) = 8
  8. _Stencil ("Stencil ID", Float) = 0
  9. _StencilOp ("Stencil Operation", Float) = 0
  10. _StencilWriteMask ("Stencil Write Mask", Float) = 255
  11. _StencilReadMask ("Stencil Read Mask", Float) = 255
  12. _ColorMask ("Color Mask", Float) = 15
  13. [HideInInspector] _FXData ("FX Data", Vector) = (0,0,0,0)
  14. [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
  15. }
  16. SubShader
  17. {
  18. Tags
  19. {
  20. "Queue"="Transparent"
  21. "IgnoreProjector"="True"
  22. "RenderType"="Transparent"
  23. "PreviewType"="Plane"
  24. "CanUseSpriteAtlas"="True"
  25. }
  26. Stencil
  27. {
  28. Ref [_Stencil]
  29. Comp [_StencilComp]
  30. Pass [_StencilOp]
  31. ReadMask [_StencilReadMask]
  32. WriteMask [_StencilWriteMask]
  33. }
  34. Cull Off
  35. Lighting Off
  36. ZWrite Off
  37. ZTest [unity_GUIZTestMode]
  38. Blend SrcAlpha OneMinusSrcAlpha
  39. ColorMask [_ColorMask]
  40. Pass
  41. {
  42. Name "Default"
  43. CGPROGRAM
  44. #pragma vertex vert
  45. #pragma fragment frag
  46. #pragma target 2.0
  47. #include "UnityCG.cginc"
  48. #include "UnityUI.cginc"
  49. #pragma multi_compile __ UNITY_UI_ALPHACLIP
  50. float4 _FXData;
  51. struct appdata_t
  52. {
  53. float4 vertex : POSITION;
  54. float4 color : COLOR;
  55. float2 texcoord : TEXCOORD0;
  56. UNITY_VERTEX_INPUT_INSTANCE_ID
  57. };
  58. struct v2f
  59. {
  60. float4 vertex : SV_POSITION;
  61. fixed4 color : COLOR;
  62. float2 texcoord : TEXCOORD0;
  63. UNITY_VERTEX_OUTPUT_STEREO
  64. };
  65. fixed4 _Color;
  66. fixed4 _TextureSampleAdd;
  67. float4 _ClipRect;
  68. v2f vert(appdata_t IN)
  69. {
  70. v2f OUT;
  71. UNITY_SETUP_INSTANCE_ID(IN);
  72. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
  73. // Get screen position
  74. float4 pos = UnityObjectToClipPos(IN.vertex);
  75. float4 screenPos = ComputeScreenPos(pos);
  76. pos.y -= sin(screenPos.x * 3.1415927) * _FXData.x;
  77. OUT.vertex = pos;
  78. OUT.texcoord = IN.texcoord;
  79. float distToEdge = _FXData.y - abs(screenPos.x - 0.5) * 2 + 0.001;
  80. float fadeOut = saturate((distToEdge - _FXData.w) / (_FXData.z + 0.0001));
  81. OUT.color = IN.color * _Color;
  82. OUT.color.a *= fadeOut;
  83. return OUT;
  84. }
  85. sampler2D _MainTex;
  86. fixed4 frag(v2f IN) : SV_Target
  87. {
  88. half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
  89. #ifdef UNITY_UI_ALPHACLIP
  90. clip (color.a - 0.001);
  91. #endif
  92. return color;
  93. }
  94. ENDCG
  95. }
  96. }
  97. }