alpha in textured GUIText?

I’ve spent way too much time now trying to hack the textured font shader into supporting color tint and alpha. I can’t seem to do it with my limited knowledge of shader programming. Anyone know how to do it - it seems like it shouldn’t be very hard…if you know what you’re doing (unlike yours truly).

Anyone know how to do it…?

…and for quick reference:
The original code from Unify:

 Shader "GUI/Textured Text Shader"
 {
 	Properties {
 		_MainTex ("Font Texture", 2D) = "white" {}
 	}
 	
 	SubShader {
 		Lighting Off
 		cull off
 		ztest always
 		Zwrite off
 		Fog { Mode Off }
 		Tags {"Queue" = "Transparent" }
 		Pass {
 			Blend SrcAlpha OneMinusSrcAlpha
 			SetTexture [_MainTex] {
 				Combine texture, texture
 			}
 		}
 	}
 }

…and my modified code, a few lines lifted from other shaders and messed with:

 Shader "GUI/Textured Text Alpha Shader" {
 
 Properties {
 	_Color ("Main Color", Color) = (1,1,1,1)
	_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
 		
 Category {
	Lighting Off
 	Blend SrcAlpha OneMinusSrcAlpha
	AlphaTest Greater .01
	ColorMask RGBA
 	cull off
 	ztest always
 	Zwrite off
 	Fog { Mode Off }
	
 	Tags {"Queue" = "Transparent" }
	
	//BindChannels {
	//	Bind "Color", color
	//}
	
	// ---- Dual texture cards
	SubShader {
		Pass {
			SetTexture [_MainTex] {
				constantColor [_Color]
				combine constant * primary DOUBLE
			}
			SetTexture [_MainTex] {
				combine texture * previous
			}
		}
	}
	
	// ---- Single texture cards (does not do color tint)
	SubShader {
		Pass {
			SetTexture [_MainTex] {
				combine texture * primary
			}
		}
	 	
 	
 	}
 }
 }

The result is that setting alpha works now, but the color isn’t blended properly. It is simply black.

Any ideas?

I’m amazed. Trial and error saves the day. :slight_smile:
I switched around the lines in the first pass - didn’t work. Commented out the first part - voila. It now works as I hoped.

// ---- Dual texture cards
	SubShader {
		Pass {
			
			SetTexture [_MainTex] {
				//combine texture * primary DOUBLE // previous
			}
			
			SetTexture [_MainTex] {
				constantColor [_Color]
				combine constant * previous
			}
		}
	}

However, I still haven’t determined:

  • exactly what I did
  • whether it’s a safe method.

I’ll read up on shaders and try to sort things out, but a comment or two from the experienced among you would be very valuable. TIA!

Dan

Hey there. I’m interested in doing the same thing as you. I’ve copied your shader script over and I get the black text but not the ability to change alpha. Can you tell me exactly how to implement this?

I too only see a black shader…

Hey Foxis - is that the final shader code you ended with? Because I cannot get even that to work. I need to change the alpha on the fly and set the color, so this shader is very interesting to me (I need it) and was wondering what progress you made?