Can we do layered materials using masks

We have a material library, I’d like to use my substance painter masks and assign materials using the mas masks.

We’re using amplify se.

I’d freaking love any help in this. I can’t figure out how to achieve this with materials and amplify and masks. This would be a life saver if anyone had ideas.

Substance already provide that shader for you but already deprecated but you can inspect them

here Adobe Community atleast you could read the code and remake it in ASE