How do I set up materials by mask properly?

Hi! Don’t know how to describe, what I want, but I’ll try. For example: I have character with 3 materials assigned - metal, leather & fabric assigned (one texture). I’ve maded 3 separate materials with different parameters to correspond them. Also I have a colour mask map (e.g blue - metal, red - leather, green - fabric). How to make material (or which material node I have to use) with the designated materials respectively colors specified in the color map mask and mix them (for example: cyan colour is mix of red&blue, so parameters of the materials leather+metal will be mixed)?