That's funny, I was doing exactly the same thing some days ago, however I'm not using a visual shader, but you should be able to replicate the code easily:
Here is where the magic happens (taken from the terrain editor plugin):
float color_sum = splat_color.r + splat_color.g + splat_color.b;
ALBEDO = (splat_color.r * col_tex_red.rgb +
splat_color.g * col_tex_green.rgb +
splat_color.b * col_tex_blue.rgb) / color_sum;
Full shader code:
shader_type spatial;
//render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx;
uniform sampler2D splat_texture;
uniform sampler2D red_texture : hint_albedo;
uniform sampler2D blue_texture : hint_albedo;
uniform sampler2D green_texture : hint_albedo;
uniform float specular;
uniform float roughness : hint_range(0,1);
uniform vec3 uv1_scale;
uniform vec3 uv1_offset;
varying vec3 splat_color;
void vertex() {
splat_color = texture(splat_texture, UV).rgb;
UV=UV*uv1_scale.xy+uv1_offset.xy;
}
void fragment() {
vec4 albedo_tex = texture(green_texture, UV);
vec3 col_tex_red = texture(red_texture, UV).rgb;
vec3 col_tex_green = texture(green_texture, UV).rgb;
vec3 col_tex_blue = texture(blue_texture, UV).rgb;
float color_sum = splat_color.r + splat_color.g + splat_color.b;
ALBEDO = (splat_color.r * col_tex_red.rgb +
splat_color.g * col_tex_green.rgb +
splat_color.b * col_tex_blue.rgb) / color_sum;
METALLIC = 0.0;
ROUGHNESS = roughness;
SPECULAR = specular;
}
I hope it helps!
edit
I see you have a base texture on color black as well, not sure how to add this, would love to know (I will test something this evening).