instead of checking the color of a fragment, and then swapping it, which is error prone due to color blending:
instead render to different images that are transparent
Have separate color mods per layer.
and then get the base color from sampling the different layers
basecolor *= baseColorMod;
for i = 0;i < layers;i++
baseColor = basecolor *(1-layerColor[i].w) + (layerColor[i].xyz * layerColor[i].w)