Font3.shader 2.7 KB

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