Halo/border in masked images This question is related to: http://blender.stackexchange.com/questions/67346/where-do-the-white-lines-come-from-in-my-composite

The solution in the above link solves for 2 render layers. I am trying to find a more generic solution that can be applied to any number of Render Layers. Below is the node structure of a shoe model that has 4 Render Layers. I have tried many variations and the closest that I could get is the one below:



To give a context, the above node structure renders masked images of shoe parts. These images are then used by a web application, which stitches and displays to the user. 

The problem that I am facing is, when the images are stitched, a Halo / transparent line / border appears in between the stitched areas. For instance, I am getting a gray border inbetween 2 stitched images as shown below:



Is there a generic solution that can get rid of the border issue, which can be extended to any number of render layers.
You're in the right track, but the implementation is wrong.

Your screenshot shows that you're combining pairs of plates together, and mix the result with an alpha over node, and that's not correct.
What you have to do here is add ALL the plates together.

So, let's say you have your renderlayers A, B, C and D.

What you need to do is add A+B, then add the result to C. The result of A+B+C has to be added finally to D.

The same goes for the alphas.

Instead of that yo are doing A+B, then C+D, and alpha over the result of one on the top of the other, which is wrong.

Start over, remove ALL the alpha over nodes, only use adds.
The only node that is not an addition you should use is only one set-alpha node, to assign the added alphas to the added RGB.