Font5.shader 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. 
  2. Shader "BFI/Font5"
  3. {
  4. Properties
  5. {
  6. _MainTex("Texture", 2D) = "white" {}
  7. _MainTex2("Texture2", 2D) = "white" {}
  8. _MainTex3("Texture3", 2D) = "white" {}
  9. _MainTex4("Texture4", 2D) = "white" {}
  10. _MainTex5("Texture5", 2D) = "white" {}
  11. _Color("Tint", Color) = (1,1,1,1)
  12. _StencilComp("Stencil Comparison", Float) = 8
  13. _Stencil("Stencil ID", Float) = 0
  14. _StencilOp("Stencil Operation", Float) = 0
  15. _StencilWriteMask("Stencil Write Mask", Float) = 255
  16. _StencilReadMask("Stencil Read Mask", Float) = 255
  17. _ColorMask("Color Mask", Float) = 15
  18. [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip("Use Alpha Clip", Float) = 0
  19. }
  20. SubShader
  21. {
  22. Tags
  23. {
  24. "Queue" = "Transparent"
  25. "IgnoreProjector" = "True"
  26. "RenderType" = "Transparent"
  27. "PreviewType" = "Plane"
  28. "CanUseSpriteAtlas" = "True"
  29. }
  30. Stencil
  31. {
  32. Ref[_Stencil]
  33. Comp[_StencilComp]
  34. Pass[_StencilOp]
  35. ReadMask[_StencilReadMask]
  36. WriteMask[_StencilWriteMask]
  37. }
  38. Cull Off
  39. Lighting Off
  40. ZWrite Off
  41. ZTest[unity_GUIZTestMode]
  42. Blend SrcAlpha OneMinusSrcAlpha
  43. ColorMask[_ColorMask]
  44. Pass
  45. {
  46. Name "Default"
  47. CGPROGRAM
  48. #pragma vertex vert
  49. #pragma fragment frag
  50. #pragma target 2.0
  51. #include "UnityCG.cginc"
  52. #include "UnityUI.cginc"
  53. #include "BFILogic.cginc"
  54. #pragma multi_compile __ UNITY_UI_ALPHACLIP
  55. struct appdata_t
  56. {
  57. float4 vertex : POSITION;
  58. float4 color : COLOR;
  59. float2 texcoord : TEXCOORD0;
  60. UNITY_VERTEX_INPUT_INSTANCE_ID
  61. };
  62. struct v2f
  63. {
  64. float4 vertex : SV_POSITION;
  65. fixed4 color : COLOR;
  66. float2 texcoord : TEXCOORD0;
  67. float4 worldPosition : TEXCOORD1;
  68. UNITY_VERTEX_OUTPUT_STEREO
  69. };
  70. fixed4 _Color;
  71. fixed4 _TextureSampleAdd;
  72. float4 _ClipRect;
  73. v2f vert(appdata_t v)
  74. {
  75. v2f OUT;
  76. UNITY_SETUP_INSTANCE_ID(v);
  77. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
  78. OUT.worldPosition = v.vertex;
  79. OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
  80. OUT.texcoord = v.texcoord;
  81. OUT.color = v.color * _Color;
  82. return OUT;
  83. }
  84. sampler2D _MainTex;
  85. sampler2D _MainTex2;
  86. sampler2D _MainTex3;
  87. sampler2D _MainTex4;
  88. sampler2D _MainTex5;
  89. fixed4 frag(v2f IN) : SV_Target
  90. {
  91. half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
  92. half4 color2 = (tex2D(_MainTex2, IN.texcoord - float2(1.0, 0)) + _TextureSampleAdd) * IN.color;
  93. half4 color3 = (tex2D(_MainTex3, IN.texcoord - float2(2.0, 0)) + _TextureSampleAdd) * IN.color;
  94. half4 color4 = (tex2D(_MainTex4, IN.texcoord - float2(3.0, 0)) + _TextureSampleAdd) * IN.color;
  95. half4 color5 = (tex2D(_MainTex5, IN.texcoord - float2(3.0, 0)) + _TextureSampleAdd) * IN.color;
  96. color *= when_le(IN.texcoord.x, 1.0);
  97. color2 *= and(when_gt(IN.texcoord.x, 1.0), when_le(IN.texcoord.x, 2.0));
  98. color3 *= and(when_gt(IN.texcoord.x, 2.0), when_le(IN.texcoord.x, 3.0));
  99. color4 *= and(when_gt(IN.texcoord.x, 3.0), when_le(IN.texcoord.x, 4.0));
  100. color5 *= when_gt(IN.texcoord.x, 4.0);
  101. color += color2 + color3 + color4 + color5;
  102. color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
  103. #ifdef UNITY_UI_ALPHACLIP
  104. clip(color.a - 0.001);
  105. #endif
  106. return color;
  107. }
  108. ENDCG
  109. }
  110. }
  111. }