wow, that is performance heavy shader.
It is quite possible, that it is unable to compare 4 floating values perfectly at runtime.
You should use mask for this kind of tasks. Isolate trousers from your png, make them black against tranmsparent background and use this as a uniform Sampler2D to mark certain area of original sprite. With this You won't need costly if
statement, You will just multiply by color or use mix
statement
uniform Sampler2D mask
uniform vec4 new
void fragment() :
float maskpixel = texture(mask, UV).a
COLOR = mix( COLOR, new, maskpixel)