Cheap way (14 instructions + 1 for the switch parameter) to separate up to 8 pure colour masks from each other using a little bit of simple maths in Unreal. Great for masking base parameters such as metallic, base colour & roughness!
https://pastebin.com/raw/cBqN4cyu - Link to raw code for copy/pasting direct into Unreal 4, here!
This shader function is free to use both for personal and commercial work, when integrated into a larger shader or as a part of a project. My only request would be to not sell or redistribute this shader function as-is as your own, but anything else goes! If you find it useful I would appreciate a shoutout, and do feel free to show or tell me how it's been useful for you if that's the case :) Especially if you end up modifying it or doing other novel things with it, I'm always keen for feedback on my tech art snippets!
Cheers!