Heres a little Blink Script that allows you to select the ObjectIDs as they come out VRay. I built in an option which will premultiply the image by the selected ObjectID. How it works, should be selfexplanatorly.
ObjectID
Updated: 18 April 2016
Author: Mr. Sheep
Compatible Nuke versions: 9.0 or later
Compatibility: