Hi Folks:

Thanks so much for your input in the past. I have been helped greatly by so many selfless posters! Anyhoo…

I’m trying to do as much as I can in a vehicle shader and am a complete noob. That being said, I came across something, modified it, and now have the following, that seems to work, but it’s a tad ugly.

I want to have a base vehicle color, and up to three masked colours for different stripes, patterns, etc. The mask uses the R, G, and B channels for each colour.

Which when using this mask (and a white base image):

Yields the following:

It seems to work OK, except there are artifacts at the edges when viewed from different distances. I can think of some reasons why, but any ideas on cleaning it up?

Here’s the shader.

```
Shader "Car Shader II" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_MaskTex ("Mask (RGBA)", 2D) = "white" {}
_Color1 ("Base Tint", Color) = (1, 1, 1, 1)
_Color2 ("Red Map", Color) = (1, 1, 1, 1)
_Color3 ("Green Map", Color) = (1, 1, 1, 1)
_Color4 ("Blue Map", Color) = (1, 1, 1, 1)
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex, _MaskTex;
float4 _Color1, _Color2, _Color3, _Color4;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
half3 m = tex2D (_MaskTex, IN.uv_MainTex);
half4 c = tex2D (_MainTex, IN.uv_MainTex);
half3 res = m;
if (m.r > .9 m.g > .9 m.b > .9) {
res = _Color1.rgb;
}
else if (m.r > .2) res = _Color2.rgb;
else if (m.g > .2) res = _Color3.rgb;
else if (m.b > .2) res = _Color4.rgb;
//Works, but chunky
//res = _Color1.rgb;
//if ((m.r > m.g) (m.r >= m.b)) res = _Color2.rgb;
//if ((m.g > m.r) (m.r >= m.b)) res = _Color3.rgb;
//if ((m.b > m.r) (m.r >= m.g)) res = _Color4.rgb;
//if (m.r > .9 m.g > .9 m.b > .9) res = _Color1.rgb;
o.Albedo = c.rgb * res;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
```