UI3D.shader 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "UI/UI3D" {
  3. Properties {
  4. _MainTex ("Font Texture", 2D) = "white" {}
  5. _Color ("Color", Color) = (1,1,1,1)
  6. }
  7. SubShader {
  8. Tags
  9. {
  10. "Queue"="Transparent+1500" //为了跟TextMesh一致
  11. "IgnoreProjector"="True"
  12. "RenderType"="Transparent"
  13. }
  14. Lighting Off
  15. ZTest Off
  16. ZWrite Off
  17. Fog { Mode Off }
  18. Blend SrcAlpha OneMinusSrcAlpha
  19. Pass
  20. {
  21. CGPROGRAM
  22. #pragma vertex vert
  23. #pragma fragment frag
  24. #pragma multi_compile _DUMMY _SEPERATE_ALPHA_TEX_ON
  25. #include "UnityCG.cginc"
  26. struct appdata_t {
  27. float4 vertex : POSITION;
  28. fixed4 color : COLOR;
  29. float2 texcoord : TEXCOORD0;
  30. };
  31. struct v2f {
  32. float4 vertex : SV_POSITION;
  33. fixed4 color : COLOR;
  34. float2 texcoord : TEXCOORD0;
  35. };
  36. sampler2D _MainTex;
  37. fixed4 _Color;
  38. uniform float4 _MainTex_ST;
  39. #if _SEPERATE_ALPHA_TEX_ON
  40. sampler2D _AlphaTex;
  41. #endif
  42. v2f vert (appdata_t v)
  43. {
  44. v2f o;
  45. o.vertex = UnityObjectToClipPos(v.vertex);
  46. o.color = v.color;
  47. o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  48. #ifdef UNITY_HALF_TEXEL_OFFSET
  49. o.vertex.xy += (_ScreenParams.zw-1.0)*float2(-1,1);
  50. #endif
  51. return o;
  52. }
  53. fixed4 frag (v2f i) : SV_Target
  54. {
  55. #if _SEPERATE_ALPHA_TEX_ON
  56. fixed4 col = fixed4(tex2D(_MainTex, i.texcoord).rgb, tex2D(_AlphaTex, i.texcoord).r);
  57. #else
  58. fixed4 col = tex2D(_MainTex, i.texcoord);
  59. #endif
  60. return col * i.color * _Color;
  61. }
  62. ENDCG
  63. }
  64. }
  65. }