In my Godot game I have a player sprite. With a shader I’m trying to make it so one color of the sprite will be changed to whatever I need it to be. In my shader it only works when I try to change the color black, but I am trying to change the color of the orange (not the light orange). I’ve tried looking at many tutorials but none of them work.
shader_type canvas_item;
uniform vec4 og_color : source_color;
uniform vec4 new_color : source_color;
void fragment() {
vec4 curr_color = texture(TEXTURE, UV);
// Define a threshold for the comparison
if (COLOR == og_color){
COLOR = new_color;
}
else{
COLOR.rgb = curr_color.rgb;
}
}
There is another problem with my version of the engine 4.2. When I reload the project, the engine seems to forget what colors were selected in the shaders parameters, despite the fact that they are displayed reliably. Only when I pick the og_color color again the shader start working as expected.