Godot Version
4.3
Question
` This may belong in the programming section because I’m not sure what I did wrong. I am making a small character creator and everything has been working perfectly until this point.
I am trying to make it so that my clothes can be changed through RBG values so it can be recolored with multiple colors. (I used pure red, green, and blue colors so for example, the shirt itself is red, but the sleeves are green). I created the shader and attached it to a .tres ShaderMaterial file, which is called in my script using const Character = preload(“res://Shaders/ColorMaskMaterial.tres”)
This shader in the inspector works, and in the inspector I can change the clothes just fine. The problem is when I run in game and use the ColorPickerButton, the colors do not change at all. I am not sure if this is a shader issue or a programming issue, but this is the shader code:
shader_type canvas_item;
uniform vec4 red_color : source_color = vec4(1.0, 0.0, 0.0, 1.0);
uniform vec4 green_color : source_color = vec4(0.0, 1.0, 0.0, 1.0);
uniform vec4 blue_color : source_color = vec4(0.0, 0.0, 1.0, 1.0);
void fragment() {
vec4 tex_color = texture(TEXTURE, UV);
vec4 final_color = tex_color; // Start with the original texture color
// Check each channel independently and ONLY modify if the channel is NOT 0
if (tex_color.r > 0.0) {
final_color.r = red_color.r;
final_color.g = red_color.g;
final_color.b = red_color.b;
}
if (tex_color.g > 0.0) {
final_color.r = green_color.r;
final_color.g = green_color.g;
final_color.b = green_color.b;
}
if (tex_color.b > 0.0) {
final_color.r = blue_color.r;
final_color.g = blue_color.g;
final_color.b = blue_color.b;
}
COLOR = final_color;
}
If I need to go into the programming section, I’m really sorry for placing this in the wrong section. I’ve been stumped on this for a while now and feel like I’m missing something very obvious.
Please let me know if you need further information! I’m desperate to get this working and feel like I’m missing a very obvious step.
Extra note:
The ColorPickerButtons do work for the skin color and eye color and hair color change, but those do not use a shader or the RBG method since they are just one color for the sprite. Since the colors of the shirt does change through the inspector, I suspect I missed something with the ColorPickerButton which is why I’m wondering if this may be a programming issue instead of a shader issue, but I wasn’t sure which category to place this question in.
I have the ColorPickerButtons set as RedColorPicker, GreenColorPicker, BlueColorPicker
`