Multi Color Text Shader

I am using the text shader from the wiki on a 3d text mesh, which allows the text to be behind other items on the screen. But it disallows the ability for the rtf tag to be used.

How can I modify the code to allow for the rtf color tags to work?

Shader "3D Text Shader" { 

Properties { 

   _MainTex ("Font Texture", 2D) = "white" {} 

   _Color ("Text Color", Color) = (1,1,1,1) 

} 

    SubShader { 

       Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 

       Lighting Off Cull Off ZWrite On Fog { Mode Off } 

       Blend SrcAlpha OneMinusSrcAlpha 

       Pass { 

          Color [_Color] 

          SetTexture [_MainTex] { 

             combine primary, texture * primary 

          } 

       } 

    }  

}

The shader code works fine for me, you just need to make sure the font is still dynamic in the Font’s Character property.

The first time I switched to this it didn’t display any text, but a quick press of Play fixed that and now it updates immediately.


Edit:
Missed the original point :slight_smile: you need to include

ColorMaterial AmbientAndDiffuse

to get the vertex colour (the RTF formatting applies it to the vertexes)

Shader “Grahams Text Shader” {

	Properties { 
	 
	   _MainTex ("Font Texture", 2D) = "white" {} 
	 
	   _Color ("Text Color", Color) = (1,0,0,1) 
	 
	} 
	 
    SubShader { 
 
       Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 
 
       Lighting Off Cull Off ZWrite On Fog { Mode Off } 
 
       Blend SrcAlpha OneMinusSrcAlpha 
 
       Pass { 
			Color [_Color] // not used
			ColorMaterial AmbientAndDiffuse // use material colour which includes vertex colour
			
			SetTexture [_MainTex] { 
				combine primary, texture * primary 

          } 
       } 
    }  
}

[25046-textshader+edit.zip|25046]

[25047-screen+shot+2014-04-11+at+10.31.55+am.png|25047]