Hi there,
I needed to decrease material draw calls on a scene so i decided to create a multi material using vertex colors.
Instead of drawing three materials, only one material is drawn.


shader_type spatial;
uniform sampler2D tex1Albedo : hint_albedo;
uniform sampler2D tex1Normal: hint_normal;
uniform sampler2D tex2Albedo : hint_albedo;
uniform sampler2D tex2Normal: hint_normal;
uniform sampler2D tex3Albedo : hint_albedo;
uniform sampler2D tex3Normal: hint_normal;
varying vec4 vertexColor;
void vertex() {
vertexColor = COLOR;
}
void fragment() {
vec3 t1 = texture(tex1Albedo, UV ).rgb;
vec3 t2 = texture(tex2Albedo, UV ).rgb;
vec3 t3 = texture(tex3Albedo, UV ).rgb;
vec3 n1 = texture(tex1Normal, UV ).rgb;
vec3 n2 = texture(tex2Normal, UV ).rgb;
vec3 n3 = texture(tex3Normal, UV ).rgb;
vec3 albedoAdd = t1 * vertexColor.r + t2 * vertexColor.g + t3 * vertexColor.b ;
vec3 normalAdd = n1 * vertexColor.r + n2 * vertexColor.g + n3 * vertexColor.b ;
ALBEDO = albedoAdd;
NORMALMAP = normalAdd;
ROUGHNESS = 0.5;
}
Next is to include roughness maps, textures resolution multiplier; and perhaps another version with more materials.
With one multi material you can create characters with extra details with one draw call; it's also good to use on level objects categories with one multi material per category.
Does Godot has a vertex painter ? It would be a nice addition to the CSG tool :)