Berenger

Font.shader (Unity)

Jun 28th, 2012
986
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. Shader "GUI/Text Shader" {
  2.     Properties {
  3.         _MainTex ("Font Texture", 2D) = "white" {}
  4.         _Color ("Text Color", Color) = (1,1,1,1)
  5.     }
  6.  
  7.     SubShader {
  8.  
  9.         Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  10.         Lighting Off Cull Off ZTest Always ZWrite Off Fog { Mode Off }
  11.         Blend SrcAlpha OneMinusSrcAlpha
  12.  
  13.         Pass { 
  14.             CGPROGRAM
  15.             #pragma vertex vert
  16.             #pragma fragment frag
  17.             #pragma fragmentoption ARB_precision_hint_fastest
  18.  
  19.             #include "UnityCG.cginc"
  20.  
  21.             struct appdata_t {
  22.                 float4 vertex : POSITION;
  23.                 float2 texcoord : TEXCOORD0;
  24.             };
  25.  
  26.             struct v2f {
  27.                 float4 vertex : POSITION;
  28.                 float2 texcoord : TEXCOORD0;
  29.             };
  30.  
  31.             sampler2D _MainTex;
  32.             uniform float4 _MainTex_ST;
  33.             uniform fixed4 _Color;
  34.            
  35.             v2f vert (appdata_t v)
  36.             {
  37.                 v2f o;
  38.                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  39.                 o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  40.                 return o;
  41.             }
  42.  
  43.             fixed4 frag (v2f i) : COLOR
  44.             {
  45.                 fixed4 col = _Color;
  46.                 col.a *= tex2D(_MainTex, i.texcoord).a;
  47.                 return col;
  48.             }
  49.             ENDCG
  50.         }
  51.     }  
  52.  
  53.     SubShader {
  54.         Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  55.         Lighting Off Cull Off ZTest Always ZWrite Off Fog { Mode Off }
  56.         Blend SrcAlpha OneMinusSrcAlpha
  57.         Pass {
  58.             Color [_Color]
  59.             SetTexture [_MainTex] {
  60.                 combine primary, texture * primary
  61.             }
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment