So I'm trying to have a shader that adds multiples textures on top of each other but I'm encountering an issue with rendering.

shader_type spatial;

// Declare the textures
uniform sampler2D base_texture : source_color, filter_nearest;
uniform sampler2D eye_texture : source_color, filter_nearest;
uniform sampler2D beard_texture : source_color, filter_nearest;
uniform sampler2D eyebrows_texture : source_color, filter_nearest;
uniform sampler2D mouth_texture : source_color, filter_nearest;

void vertex() {
    // nothing here for now
}

void fragment() {
    // Sample colors from both textures
    vec4 base = texture(base_texture, UV);
    vec4 eye = texture(eye_texture, UV);
    vec4 beard = texture(beard_texture, UV);
    vec4 eyebrows = texture(eyebrows_texture, UV);
    vec4 mouth = texture(mouth_texture, UV);
    vec3 temp1 = mix(base.rgb, eye.rgb, eye.a);
    vec3 temp2 = mix(temp1.rgb, beard.rgb, beard.a);
    vec3 temp3 = mix(temp2.rgb, eyebrows.rgb, eyebrows.a);
    vec3 temp4 = mix(temp3.rgb, mouth.rgb, mouth.a);


    // Output the final color with transparency
    //ALBEDO = mix(base.rgb, eye.rgb, eye.a);
    ALBEDO = temp4.rgb;
    METALLIC = 0.0;
    ROUGHNESS = 0.5;
    SPECULAR = 0.0;
}

First one is the issue one done with shader

This one is made with a normal spatial material with the multiples next pass.

I also tried a visual shader to see :

Same issue :

So, any ideas ?
To be clear, the issue seems to be that the texture on top seems to have issues with transparency.
Black becomes brown, etc.

  • xyz replied to this.

    Loxyrak Why do you use nearest neighbor texture filtering? Try linear instead.

      xyz Nearest and linear doesn't seem to affect the bug I have, it has the same issue with both.

      • xyz replied to this.

        Loxyrak What exactly is the issue? The only thing I see in your images is pixelization caused by the lack of texture interpolation.

        Nevermind, I'm dumb, it's solved, thanks !