Yes, the problem comes from the anti-aliasing in the Index passes.
I remember I was worried about it at the beginning, but I could not find a good solution for it.
For example, even if I managed to remove the antialiasing, still I have this problem:
* Imagine you have the background, one object and another object partially overlapping the first object (partially in front of it).
* If you have antialiasing (as of now), the edges of the objects will not have the "correct" ObjectID/MaterialID. In fact they will probably have a number not belonging to any as the edge would be a bit "mixed" with samples from background and/or object1 and/or object2
However, in I managed to remove the antialiasing, what should happen with the boundaries between objects and between objects and background? Due to the nature of the render, the pixels at the edges receive contribution from the two objects/background. What criteria should we use to decide to which object those pixels belong without antialiasing?
Also, I noticed that without antialiasing using masking operations would cause pixels in the edge that are ugly, and sometimes getting thin high contrast parts of the other object.
So, this is my dilemma... at the time I decided to keep it as it was (with antialiasing) as for me it was the "lesser evil", but I'm open to any ideas to improve it!!
Thanks and best regards.