I’m trying to interpolate between 3 textures on a landscape using an alpha map and CG. Here’s the code
float4 main(in float4 wpos : WPOS,
float2 tex1coords : TEXCOORD0,
float2 tex2coords: TEXCOORD1,
float2 tex3coords: TEXCOORD2,
float2 tex4coords: TEXCOORD3,
uniform sampler2D tex1 : TEXUNIT0,
uniform sampler2D tex2 : TEXUNIT1,
uniform sampler2D tex3 : TEXUNIT2,
uniform sampler2D tex4 : TEXUNIT3
): COLOR
{
float3 a = tex2D(tex1, tex1coords).rgb;
float3 b = tex2D(tex2, tex2coords).rgb;
float3 c = tex2D(tex3, tex3coords).rgb;
float3 d = tex2D(tex4, tex4coords).rgb;
float3 e = tex2D(tex5, tex5coords).rgb;
float3 color1 = lerp(c, a, b.x);
float3 color2 = lerp(d, color1, b.y);
return float4(color2, 1.0);
}
The output consists of the 1st and 2nd textures, but not the third. The alpha map has 3 blotches of red, green, and blue and the rest is white. The the first texture should show through at white, the 2nd at red, the 3rd at green and NOTHING should show through at blue.
But instead, the 3rd shows through at blue. Am I accessing the components of the texture correctly using .x, .y ?? I’ve tried using .r, .g, .b but I get the same result.