Using material ID textures in Blender to separate materials

I’m having a hard time finding a node setup for using material ID textures in eevee that works. I am trying to convert each color into a mask for combing different material settings. All of the color detection node setups that I have tried all result in a scintillating, sparkly edge along the mask edges that I can’t get to go away. The latest I’ve tried is using a math compare node with the texture and a color as an input. Any game dev pros have a solution here?