Mix nodes and alpha (Blender internal)

Hi!
Can someone please give me a short rundown of how the mix node handles alpha?

I have two render layers, one which is opaque in the lower half and transparent in the upper half and one with the opposite. I try to use the mix node to combine the images but it does not work as I expected. Doesn’t the mix node take alpha values into account?


I actually can achieve the correct result using an alpha over node, but I would like to understand why the mix node does not work.

Also, the reason for splitting the render layers (in case someone wonders) is to make the cloud (gray image) fade with z-values. I manage to do so by using the z-buffer, a normalize node, a color ramp and a set alpha node.

Try enabling the small box to the right of ‘Mix’ to include the alpha
http://wiki.blender.org/index.php/Doc:2.4/Manual/Composite_Nodes/Types/Color#Mix_Node

Attachments


Depends on the setting. Mix, add, screen, multiply, and the rest all manipulate the pixels differently. A google of “photoshop modes” will give you some of the answers you are lookng for (photoshop modes and mix node are very similar)

Ah! I thought I had tired the alpha button, but apparently I am a fool. Thank you for the help!

Also thanks to place57 for guiding me to some interesting reading. I will read up on all the different blending modes. So far I have only found need of mix and add, but I guess it does not hurt to know them all.

Hmm… it is a bit strange that the preview window of the mix node shows just the upper image. Also, this is the same image I see in the backdrop if I press the “Color and the alpha” button in the Image-view window (where you choose Channels of the image to draw).

This means that the lower half of the image (the yellow part in your example) actually has an hidden alpha value of 0 for some reason. And it also means that if I save the image to a png with an alpha channel RGBA (which I want to do) I will only see half of my image.

Is this a bug in how the “mix mode” (in the mix node) works? My understanding is that it should result a blended color (weighted on the two alpha values) and an alpha value of 1 whenever at least one of the images has alpha 1.

Actually, in the manual it clearly states that the resulting image should have a mixed result for the alpha channel as well. However, a quick test shows that this is not the case. Either the mix node is not working properly or the manual is wrong (or, perhaps most probably, I am doing something terribly wrong).

Below is a set up to show my point. I have put viewer nodes to show the alpha of the different layers and then the combined layer. No matter what setting I use (alpha or no alpha, and any of the modes; mix, multiply, etc) the resulting value of the alpha is just the same as the incoming image.


In the manual for the mix node it is written that:

AClick the green Alpha button to make the mix node use the Alpha (transparency) values of the second (bottom) node. If enabled, the resulting image will have an Alpha channel that reflects both images’ channels. Otherwise, (when not enabled, light green) the output image will mix the colors by considering what effect the Alpha channel has of the base (top input socket) image. The Alpha channel of the output image is not affected.
So, if I understand things correctly, either the mix node does not work as it should or the manual is wrong.

I’ve resigned myself long ago to the notion that “alpha” and “color” really are entirely-different beasts. RGB data can be combined in an ordinary mix-operation, but alpha usually has to be treated differently … “maximize” or “minimize,” usually, just because of the nature of the beast. (Mixing translucent with translucent doesn’t make it more, or less, translucent.) It’s a fly in the ointment of your node-network noodle, but I guess it has an excuse for being there.

Yes I would guess that the math ahndling for alpha should not just be a simple mix but multiply, so split it out if you need to add two translucent images.

I checked the developer bugg reports and this was reported a while back and it was responded that the mix-node always returns the upper input’s alpha channel and that this is what is suppose to happen.

Also, I got to hear that they are currently working on the mix node to add some options for the alpha.

The problem hence is that the user manual is a bit misleading (or perhaps even wrong).