How do I get rid of strange border produced when mixing images?

In the attachment below i notice that when I mix two images using object index as a fac and inverting it produces a strange border around my image.



Here is my node setup:


Can anyone tell me how to get rid of this border?

Use alpha over at the end instead of mix, turn on premult.

Would you mind posting an example setup, because I’m a bit confused here. Thanks.

IndexOB output stores the information about ALL indexes you have in your render.
It’s a mistake to use it directly.
I assume that you specified the index of the object the you are interested in. Let’s assume that you set it to 1.


Then before you invert the mask based on index you’d rather first extract it using Convertor => ID Mask node.
There you have the option “Anti-Aliasing”. Turn it on and see what happens. This should improve your result, but sometimes anyway you may encounter issues. In such case try to additionally play with dilate/erode node.


Oops I didn’t even notice where the key was derived from, sorry.