Help with transparency .png

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DarlesLSF

How can I set the transparency color on godot?

:bust_in_silhouette: Reply From: Jay Kyburz

I don’t know if you can set a colour to be transparent, but what you probably want to do is create a transparency channel in your paint program, then make sure to export your png with that transparency.

:bust_in_silhouette: Reply From: Eric Ellingson

You can use a shader:

shader_type canvas_item;

uniform vec4 from_color : hint_color;
uniform vec4 to_color : hint_color;

void fragment() {
    vec4 curr_color = texture(TEXTURE, UV);

    if (curr_color == from_color){
        COLOR = to_color;
    }else{
        COLOR = curr_color;
    }
}

the from_color and to_color uniforms are basically exported variables that you can then set in the Shader Param section:

enter image description here

from_color is the color that you want to change in your sprite or whatever. to_color is the color you want from_color to change to. In your case, you can set that to be fully transparent.