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.