In this shader there are 2 images that will always exist: base_texture and frame_texture. But sometimes an object that uses this shader can also have an optional texture: overlay_texture. How can I check if this texture was sent or if it is <empty>?
I found a tip to check the alpha of the optional texture and only use it if it is greater than 0.0, but when I do this it only leaves a white image and not the combination that should exist.
shader_type spatial;
uniform sampler2D base_texture : source_color;
uniform sampler2D frame_texture : source_color;
uniform sampler2D overlay_texture : source_color;
void fragment() {
vec4 base_color = texture(base_texture, UV);
vec4 frame_color = texture(frame_texture, UV);
vec4 overlay_color = texture(overlay_texture, UV);
vec4 combined_color = mix(base_color, frame_color, frame_color.a);
vec4 final_color;
if (overlay_color.a > 0.0) {
final_color = mix(combined_color, overlay_color, overlay_color.a);
} else {
final_color = combined_color;
}
ALBEDO = final_color.rgb;
ALPHA = final_color.a;
}
Is there any correct way to check if the texture is set or <empty>?