# What does the MixRGB or Mix Shader node factor do exactly?

So on both the mixRGB and the mix shader nodes there is a factor input.

But what exactly does the node do? I know that in the case of mix RGB it has something to do with the probability light rays hit either material and that in the case of mix shader the node performs some kind of linear interpolation between the base layer image and the resulting image.

But is that really all there is to it?

Thanks!

• The Factor input on its own is a linearly interpolated blend between the two inputs - the Factor can also be used as a socket for a black and white mask texture that will define the blend areas based on its parameters (light and dark areas). Feb 16, 2022 at 18:16

The MixRGB node has two color inputs and a drop down menu, as well as the Factor input.

Each entry in the drop down menu selects a function that is applied to the two inputs to produce the output. In some cases, the Factor input is used in the equation to control how much of the affect is applied. In other cases it is ignored.

Here are some examples, using $$a$$ for the top color, $$b$$ for the bottom color, and $$fac$$ for factor

• Mix: $$a + (b - a) * fac$$; Most useful for using a mask as the factor to select between an image versus a background color;
• Darken: $$min(a, b)$$;
• Multiply: $$a * b$$ [ie, $$a_r * b_r$$, $$a_g * b_g$$, $$a_b * b_b$$];
• Color Burn: $$1 - ( (1 - a) / b)$$; can be used as to do things like setting the width of mortar. Set $$a$$ to a gradient (IE, the X coordinate, Set $$b$$ to 0. Then color burn effectively goes black from 0 to factor and then is a gradient from factor to 1. NOTE: always clamps to [0..1]
• Lighten: $$max(a, b)$$;
• Color Dodge: $$a / (1-b)$$; the opposite of color burn Does not clamp the negative [-inf..1]
• Add: $$a + b$$; useful for layering displacement maps.
• Linear Light: $$(a + 2*b) - 1$$; Factor is important to this; but the big thing is that you can use it to add noise and control the noise. Put the noise in b. The basic shape of a doesn't change but factor acts to attenuate the noise. It's a good way to add noise to coordinates.
• Difference: $$abs(a - b)$$

The Mix Shader node has two color inputs but no drop down. It uses the same equation as the Mix mode of the MixRGB node.

• Source code for reference. Usually the factor lerps between a and f(a,b), where f is the named function eg. a*b for Multiply. Feb 16, 2022 at 19:49
• Thanks @scurest Feb 16, 2022 at 20:13
• I like a+(b−a)∗fac as opposed to a∗(1-fac) + b∗fac 🙂 Worth a note the Factor is still used in every mode, where b becomes the result of the formula. Feb 16, 2022 at 22:40
• Well I'm aware that usually the fac input results in a lerp operation, but is that always the case, since it is also sometimes part of the color blénding functions? Feb 17, 2022 at 15:04
• @tempdevnova that's correct, as witness the way the Mix or difference operators are implemented. Feb 17, 2022 at 15:27