Advertisement
Guest User

AlwaysOnTop

a guest
May 21st, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. Shader "Custom/AlwaysOnTop" {
  2. Properties {
  3. _MainTex ("Font Texture", 2D) = "white" {}
  4. _Color ("Text Color", Color) = (1,1,1,1)
  5.  
  6. _StencilComp ("Stencil Comparison", Float) = 8
  7. _Stencil ("Stencil ID", Float) = 0
  8. _StencilOp ("Stencil Operation", Float) = 0
  9. _StencilWriteMask ("Stencil Write Mask", Float) = 255
  10. _StencilReadMask ("Stencil Read Mask", Float) = 255
  11.  
  12. _ColorMask ("Color Mask", Float) = 15
  13. }
  14.  
  15. SubShader {
  16.  
  17. Tags
  18. {
  19. "Queue"="Transparent"
  20. "IgnoreProjector"="True"
  21. "RenderType"="Transparent"
  22. "PreviewType"="Plane"
  23. }
  24.  
  25. Stencil
  26. {
  27. Ref [_Stencil]
  28. Comp [_StencilComp]
  29. Pass [_StencilOp]
  30. ReadMask [_StencilReadMask]
  31. WriteMask [_StencilWriteMask]
  32. }
  33.  
  34. Lighting Off
  35. Cull Off
  36. ZTest Off
  37. ZWrite Off
  38. Blend SrcAlpha OneMinusSrcAlpha
  39. ColorMask [_ColorMask]
  40.  
  41. Pass
  42. {
  43. CGPROGRAM
  44. #pragma vertex vert
  45. #pragma fragment frag
  46.  
  47. #include "UnityCG.cginc"
  48.  
  49. struct appdata_t {
  50. float4 vertex : POSITION;
  51. fixed4 color : COLOR;
  52. float2 texcoord : TEXCOORD0;
  53. };
  54.  
  55. struct v2f {
  56. float4 vertex : SV_POSITION;
  57. fixed4 color : COLOR;
  58. float2 texcoord : TEXCOORD0;
  59. };
  60.  
  61. sampler2D _MainTex;
  62. uniform float4 _MainTex_ST;
  63. uniform fixed4 _Color;
  64.  
  65. v2f vert (appdata_t v)
  66. {
  67. v2f o;
  68. o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  69. o.color = v.color * _Color;
  70. o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
  71. #ifdef UNITY_HALF_TEXEL_OFFSET
  72. o.vertex.xy += (_ScreenParams.zw-1.0)*float2(-1,1);
  73. #endif
  74. return o;
  75. }
  76.  
  77. fixed4 frag (v2f i) : SV_Target
  78. {
  79. fixed4 col = i.color;
  80. col.a *= tex2D(_MainTex, i.texcoord).a;
  81. clip (col.a - 0.01);
  82. return col;
  83. }
  84. ENDCG
  85. }
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement