In the shader below, I am trying to render a default color when no lighting is applied to the pixel. Notice that I’m simply setting the color in the surface shader to green. However the result has the green color blended with the default color (red). _BaseColor = red.
If I comment out the line color = _BaseColor then the result is the green color expected.
Any help would be great, thanks!
SubShader {
Tags { “RenderType”=“Opaque” }
LOD 200
Cull Back
CGPROGRAM
#pragma surface surf Lambert finalcolor:finalcolor
sampler2D _MainTex;
float4 _BaseColor;
struct Input {
float2 uv_MainTex;
};
void finalcolor (Input IN, SurfaceOutput o, inout fixed4 color)
{
if (color.g == 0)// && color.g == 0.0 && color.b == 0.0)
{
color = _BaseColor;
}
}
void surf(Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
//o.Albedo = c.rgb;
//o.Alpha = c.a;
o.Albedo.r = 0;
o.Albedo.g = 1;
o.Albedo.b = 0;
o.Alpha = 1;
}
ENDCG