you can extract a very large amount of masks from rgb textures. you could - for example - compare the channels of your mask texture with the channels of a sample color and make a mask from that.
there are most likely more ways to go about that with less instructions and nicer masks, but that’s just what came to my head :X
// i changed the threshold for the equal in the if nodes to get a wider range.
