You can also vertex paint/ID paint your mesh before importing it into Substance Painter. Its really quick and easy and doesn't leave you with more than one material and only the UV spaces you need. Just make sure you pick the right ID map when baking in SP
i wrote a plugin that sets it all up and does the merging for you a few years ago at work but can't share it for obvious reasons. that's how it worked though
No worries. I kinda get the idea of what you said. I just placed a fill layer with different color on each texture set and exported just the base color to use as color mask.
to get masks you can use in photoshop... set up a user channel in each texture set put a black fill layer that only writes into the user channel and that covers everything add a white fill layer that only writes into the user channel and and that only covers the geometry add the user channel to your export preset export..…