Compositing problem with alpha

I have difficulties understanding what’s happening in my setup. I have several cubes on one render layer and I want to add different kinds of glow around them. The cubes are not overlapping. I use material indexes and ID Masks to apply a blur filter on the edges of each cube. At the end I want to combine all of them to one image to afterwards combine it with the rest of the layers.

Here’s what I have. If I look at the result of the nodes for the blue cube, it looks fine.


The same with the orange cube:


Although here the glow looks to yellowy, compared to what I chose as colour in the set alpha node.

Now I combine them with alpha over (I tried colour mix too):


As you can see, the blue cube and the glow around the orange one got a new colour. Which is what I don’t understand, because on each combined image there is “nothing”/transparency where the respective other cube is.
By trying a few other things, for example by “alpha overing” the “set alpha” nodes after the sobels, which also result in weird colours, I conclude that my problem lies somewhere around the ID Mask -> Sobel -> Set Alpha nodes.

Which is what I don’t understand, because on each combined image there is “nothing”/transparency where the respective other cube is.

Actually, there is something. The image you made transparent. :wink:

Blender by default expects alpha to be premultiplied, in which case fully transparent areas are always black. As it happens, you have color in transparent sections due to how your alpha channel came into existence via the ID Mask and Set Alpha. The alpha channel never gets premultiplied, but Alpha Over does its thing expecting that it was. So you need to add the premult. You can either enable the “convert premul” checkbox on the alpha over nodes (so it is expecting straight alpha, which is what your setup creates), or add the “alpha convert” node right after Set Alpha to do the conversion there.

Thank you.

Actually, there is something. The image you made transparent

It felt like there was something that is not visible :wink:

I read up on the alpha concepts, and things are now beginning to make sense.
For your information: when checking the “Convert Premul” boxes on the alpha over nodes it doesn’t work (I actually tried that before, without knowing what I’m doing ;)) it has to be the alpha convert nodes. Sadly I can’t find any real documentation about the alpha node to know what’s going on there in detail. Also, when checking the boxes and using the alpha convert nodes, it’s still working, but I expect it to not work because the Alpha Over is now expecting Straight Alpha and getting Premul Alpha…

Now it’s also clear to me why the orange was yellowy.