Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | DarlesLSF |
How can I set the transparency color on godot?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | DarlesLSF |
How can I set the transparency color on godot?
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.
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:
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.