If you don’t actually need to tint a texture, but rather, are just using flat colors, then it would be better to change the colors of different parts of your texture to be masks in a channel, instead of colors that are a mix of different channels (like brown). This does that; it should either work for you, or help show you that you haven’t provided all the necessary information.
Please forgive the lack of formatting; navigating this box on iOS is infuriating. Sorry about the GLSL if you’re on Windows, but I haven’t had time or a reason to learn Cg.
Shader “4-Colorize” {
Properties {
_MainTex (“Color Masks”, 2D) = “” {}
_RedColor (“Color for Red Texture Channel”, Color) = (1,0,0,1)
_GreenColor (“Color for Green Texture Channel”, Color) = (0,1,0,1)
_BlueColor (“Color for Blue Texture Channel”, Color) = (0,0,1,1)
_AlphaColor (“Color for Alpha Texture Channel”, Color) = (1,1,1,1)
}
SubShader {
Tags {“Queue”=“Transparent”}
ZWrite Off
Blend One OneMinusSrcAlpha
Pass {
GLSLPROGRAM
varying mediump vec2 uv;
#ifdef VERTEX
void main() {
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
uv = gl_MultiTexCoord0.xy;
}
#endif
#ifdef FRAGMENT
uniform lowp sampler2D _MainTex;
uniform lowp vec4 _RedColor, _GreenColor, _BlueColor, _AlphaColor;
void main() {
lowp mat4 colors = mat4(_RedColor, _GreenColor, BlueColor, AlphaColor);
for (int i = 0; i < 4; ++i) colors.rgb = colors.a;*
gl_FragColor = colors * texture2D(_MainTex, uv);
* }*
* #endif*
* ENDGLSL*
* }*
}
}