Color fill a texture

Can someone teach me how I’d modify this mobile transparent unlit shader so that it fills the texture area with a single solid color, while retaining the alpha channel as a mask? I know some basics of ShaderLab but not how to replace the texture entirely with a color (instead of tinting the texture). Seems easy though.

Shader "Mobile/Unlit/Transparent" {

	Properties {
	    _Color ("Main Color (A=Opacity)", Color) = (1,1,1,1)
	    _MainTex ("Base (A=Opacity)", 2D) = ""
	}

	Category {
	    Tags {"Queue"="Transparent" "IgnoreProjector"="True"}
	    ZWrite Off
	    Blend SrcAlpha OneMinusSrcAlpha 

	    SubShader {Pass {
	        GLSLPROGRAM
	        varying mediump vec2 uv;

	        #ifdef VERTEX
	        uniform mediump vec4 _MainTex_ST;
	        void main() {
	            gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;	
	            uv = gl_MultiTexCoord0.xy * _MainTex_ST.xy + _MainTex_ST.zw;	
	        }
	        #endif

	        #ifdef FRAGMENT
	        uniform lowp sampler2D _MainTex;
	        uniform lowp vec4 _Color;
	        void main() {	
	            gl_FragColor = texture2D(_MainTex, uv) * _Color;	
	        }
	        #endif      
	        ENDGLSL	
	    }}

	    SubShader {Pass {
	        SetTexture[_MainTex] {Combine texture * constant ConstantColor[_Color]}
	    }}
	}
}

Ah, I figured this would be easy. Maybe not so much…? :slight_smile:

Tried it. Threw a couple of errors:

Shader warning in ‘Mobile/Unlit/Transparent Color Fill’: No subshaders can run on this graphics card
Shader error in ‘Mobile/Unlit/Transparent’: GLSL Error in Fragment Shader: ERROR: 0:59: ‘c’ : syntax error syntax error
at line 0

Cool, it’s working nicely! Thanks, meh…

No, no, I really am thankful… I’m not shrugging as I say that but… meh.