Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | exuin |
As soon as I change const vec4 REPLACE_1 = vec4(1.0);
to uniform vec4 REPLACE_1 = vec4(1.0);
, the shader turns into some random white rectangle. What’s the error here?
shader_type canvas_item;
const vec4 REPLACE_1 = vec4(1.0);
const vec4 REPLACE_2 = REPLACE_1 - vec4(.25, .25, .25, 0);
const vec4 REPLACE_3 = REPLACE_2 - vec4(.25, .25, .25, 0);
const vec4 REPLACE_4 = REPLACE_3 - vec4(.25, .25, .25, 0);
const vec4 COLOR_1 = vec4(230.0/255.0, 69.0/255.0, 57.0/255.0, 1);
const vec4 COLOR_2 = vec4(173.0/255.0, 47.0/255.0, 69.0/255.0, 1);
const vec4 COLOR_3 = vec4(120.0/255.0, 29.0/255.0, 79.0/255.0, 1);
const vec4 COLOR_4 = vec4(79.0/255.0, 29.0/255.0, 76.0/255.0, 1);
void fragment() {
COLOR = texture(TEXTURE, UV);
if (COLOR == COLOR_1){
COLOR = REPLACE_1;
} else if (COLOR == COLOR_2){
COLOR = REPLACE_2;
} else if (COLOR == COLOR_3){
COLOR = REPLACE_3;
} else if (COLOR == COLOR_4){
COLOR = REPLACE_4;
}
}