#002 - Unpremult and Premult

Updated: Mar 3, 2020


After some time, you may have noticed a node called Unpremult and its sister called Premult. You may be asking yourself, “What is a Premult and how do I use it?”

Well today is your lucky day! In this post, we’ll go over exactly what they are, how to use them and why you would want to. I’m going to explain this in two ways. A simple way and a more advanced way.

Simply, the Unpremult will spread the image open and give you the full value of the pixels without transparency.

This allows you to apply a Grade to the pixels evenly, giving them the same grade treatment. When you finish your grade, you then apply a Premult to give the original transparency back onto the pixels.

The more advanced way is learning the math behind it. The Unpremult divides RGB values by their alpha. For example, a pixels’ red value is 0.01897 and its’ alpha value is 0.16244. Once unpremulted, the new red value is 0.11678. You can now Grade all the pixels at their full values before transparency is applied back onto them.

After you Grade the image, you then Premultiply it. Say your grade changed the red value above (0.11678) and is now 0.25913. Once you Premultiply it by its’ alpha, the new graded red pixel value would be 0.04209.

This method of grading *can* be preformed anywhere in your Nuke script. With that being said, I personally recommend doing this before your render passes are combined. (Diffuse, Spec, Reflection, GI, etc) should all have their own Unpremult, Grade, and Premult. Doing it this way allows you to have the colour you want BEFORE all of the other processing you need to do. (Motion blur, DOF, etc).

Here’s another example of the Premult math at work. I have a ColorWheel and I’m looking at it’s edge. You can see the selected pixel has an alpha of 0.22037. Keep in mind, the pixel above that one has an alpha value of 1.

Let’s put a bunch of Premult nodes right onto this ColorWheel and see what happens.

You can see that the pixels with an alpha less than a solid 1 keep being multiplied until there is nothing left. This is because if any pixel value is multiplied by an alpha value of 1, it does not change. Any number multiplied by 1 is 1. But any pixel value with an alpha less than 1, will multiply itself again and again and again.

Keeping that in mind, lets create a Roto and make a shape inside of the ColorWheel. Then we will use a Copy node and copy the alpha into the ColorWheel, this makes it the “new” alpha.

Now lets add a Premult under the Copy and view it. You can see that the Premult “cut out” all RGB values that did not have an alpha in them. Again, this is because where there is no alpha, you are multiplying by 0, resulting in 0.

To recap, “Premult” means “Pre-Multiply”. This node will multiply all RGB values by their alpha values. Similarly, “Unpremult” means “Un-Pre-Multiply”. This node will divide all RGB values by their alpha values.

I hope this has helped you get a deeper understand of these nodes and why we use them. I’ve made a video about this topic as well so feel free to check that out!

Thanks for reading! If you’ve got any questions, topic suggestions, or just want to say hi, please leave a comment. Don’t forget to subscribe to my YouTube channel for more videos and to my Blog for post updates!

#PremultUnpremult

814 views0 comments

Recent Posts

See All