I tried that but it just renders as 1 material even thought the object has 2 different materials and corresponding selection sets. I have also tried with an Mask pass with material ID which should work. It looks like the problem happens when I have Corona convert materials from Sketchup. Even if the material whose mask I want is a Corona material it will not render the mask. If I delete the converted materials and use 2 corona materials it renders the mask fine.