Unlit - Dynamic Font.shader 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Unlit/Dynamic Font"
  3. {
  4. Properties
  5. {
  6. _MainTex ("Alpha (A)", 2D) = "white" {}
  7. }
  8. SubShader
  9. {
  10. Tags
  11. {
  12. "Queue"="Transparent"
  13. "IgnoreProjector"="True"
  14. "RenderType"="Transparent"
  15. }
  16. Cull Off
  17. Lighting Off
  18. ZWrite Off
  19. Fog { Mode Off }
  20. Offset -1, -1
  21. AlphaTest Greater .01
  22. Blend SrcAlpha OneMinusSrcAlpha
  23. Pass
  24. {
  25. CGPROGRAM
  26. #pragma vertex vert
  27. #pragma fragment frag
  28. #pragma fragmentoption ARB_precision_hint_fastest
  29. #include "UnityCG.cginc"
  30. struct appdata_t
  31. {
  32. float4 vertex : POSITION;
  33. fixed4 color : COLOR;
  34. float2 texcoord : TEXCOORD0;
  35. };
  36. struct v2f
  37. {
  38. float4 vertex : POSITION;
  39. fixed4 color : COLOR;
  40. float2 texcoord : TEXCOORD0;
  41. };
  42. sampler2D _MainTex;
  43. uniform float4 _MainTex_ST;
  44. v2f vert (appdata_t v)
  45. {
  46. v2f o;
  47. o.vertex = UnityObjectToClipPos(v.vertex);
  48. o.color = v.color;
  49. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  50. return o;
  51. }
  52. fixed4 frag (v2f i) : COLOR
  53. {
  54. fixed4 col = i.color;
  55. col.a *= tex2D(_MainTex, i.texcoord).a;
  56. return col;
  57. }
  58. ENDCG
  59. }
  60. }
  61. SubShader
  62. {
  63. Tags
  64. {
  65. "Queue"="Transparent"
  66. "IgnoreProjector"="True"
  67. "RenderType"="Transparent"
  68. }
  69. Lighting Off
  70. Cull Off
  71. ZTest Always
  72. ZWrite Off
  73. Fog { Mode Off }
  74. Blend SrcAlpha OneMinusSrcAlpha
  75. BindChannels
  76. {
  77. Bind "Color", color
  78. Bind "Vertex", vertex
  79. Bind "TexCoord", texcoord
  80. }
  81. Pass
  82. {
  83. SetTexture [_MainTex]
  84. {
  85. constantColor [_Color] combine constant * primary, constant * texture
  86. }
  87. }
  88. }
  89. }