Understanding Premult and Unpremult in NUKE

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I'm going to learn about pre mold and unmold in Nuuk and how important they are for color correction workflows okay so I have three images here that we're going to be working with and just as a quick little preview for you I'll go ahead and hook my viewer up to those I've got a read node which is my background another read of the RGB of this dragon with a little bit of motion blur and then the alpha for that dragon now if you're new to nuke you may wonder why is the alpha red if you know anything about alpha channels you'd probably expect for that to be black and white and generally alpha channels are black and white and they are used in nuke the same way as far as how the black and white information is read but depending on how something is rendered if it's only been rendered as an alpha channel and just has the one channel and isn't rendered as an RGB a image then the alpha channel just automatically gets dumped into the red Channel because it's the first channel there so if I come in here and I say I want to view my red Channel you can see that we do get that black and white information if I go to my alpha there's nothing there because it's in the red Channel so that's a quick little note about nuke and that it handles this maybe a little bit differently than you what you might expect it just is automatically dumping that alpha into the red so keep that in mind as we continue to work through this tutorial so pretty molten unmold nodes in nuke they can really sometimes be overlooked by beginners because the effects of using them or lack of using them can create other effects that may not seem to be too apparent until you get up really close or you make a really large change or if you do some other kind of maybe double pre-multiplication or something like that then you can start to see certain little things but to the untrained eye it still kind of looks okay so you need to be aware of these types of things and make sure that you aren't having these small mistakes come through into the final pieces of your work so what is pretty multiplication it's a term referring to the math that's happening behind the scenes when you're placing a foreground image over a background image so that's what I want to do here I want to place this dragon on top of this background image now to be able to do this normally a new guy would use a merge node so I'm going to hit the tab key and type in merge and drop that on so that my B pipe is going to my read node and my a pipe is going to my dragons read node now you can see that we are getting a pre multiplication around these edges here but we're also getting in in some of the other areas so the math is not working correctly right now and I want to talk about why it looks like this before you add the alpha so but and we're actually going to look over at the alpha kind of while we talk about this and I'm going to look at it in just the black and white image here so premultiplication as I said is getting that foreground image on top of your background image now the key to that looking correct is that there is a third image present that images this alpha that we're seeing here now the Alpha image or alpha channel is made of black and white and sometimes as in this case you can see grey for semi-transparent areas the totally black areas in an alpha channel are going to equal zero and the white area is equal one this is a great thing about nuke is that it measures things from 0 to 1 and pretty much everything is measured on that scale with 1 being the brightest white and 0 being the darkest black within normal ranges at least so in math we know that 1 times any number equals the same number 1 times 10 is 10 1 times 5 is 5 it's the same number there's no change we also know that 0 times any number equals 0 0 times 10 is 0 0 times 5 is 0 0 times 2 is 0 everything is 0 if it's multiplied by 0 that's what we are always going to get so with that in mind if these colors have been assigned those values that's where we start to get this math equation that happens whenever an image is merged with another image and we get this pre multiplication so we're automatically going to get a pre multiplication when we merge these together it's just not going to be the right kind of math because you can see he looks kind of semi-transparent so if we're looking just at the RGB values here what's happening is the black areas in this render of our dragon they are becoming transparent and the lighter area is the closer to white areas are still visible so it's trying to use the its own image to create this dragon for us and that's not what we want we want it to use the Alpha channel to define that so we need to use a shuffle copy node to bring this alpha channel into our calculation so I'm going to hit the tab key and type in shuffle copy and when you're using a shuffle copy you'll want to plug the alpha into the 1 pipe and the 2 into your RGB now I'm going to hook my a pipe from the merge into the shuffle copy now you can see we didn't have a change yet because the shuffle Coffey copy by default is going to dump the Alpha in here but we know that our alpha is in the red channel so I'm just going to move that over and now we get the correct image so what's happening here is that the white values of my alpha when multiplied by my foreground image I'm just going to kind of toggle back and forth between these two the white values or as you can see here those red values because we're dumping it into the Alpha channel are being multiplied by my foreground they are preserving or not changing this area here where it's coinciding with the red so it's preserving those to be fully opaque now the black values of my alpha when overlapped with this area here this black area outside of my Dragon those are going to equals zero which makes them transparent so now when I look at my merge I have a transparent outside of the Dragon and any other areas that were black or not being poured into this alpha channel here rather the are so you can see that these areas right here are what we're seeing here so this is pretty basic this is compositing at the most basic of levels but this operation because it involves math a lot of people really don't take the time to learn how it kind of affects things further down the line once you start doing things like color correction and this is where things can start to get tricky and understanding how it works behind the scenes the way we just went through is really going to help you understand why color correction can cause a breakdown in the way that it is causing that math to be calculated so what I'm going to do is kind of scoot this over here and we're going to add a grade node so I'm going to hit the tab key and add this grade node in so I can do a little color correction and the first thing I want to do is come in here and crank up that offset so this is one of the telltale signs of something going wrong with your maths the grade is affecting my background image before I ever even have really merged in with the background because you can see this is before the merge now what's happening here is that whenever I look at this grade I'm going to point to this the black areas are being lightened so these no longer equals zero they equal some value between 0 & 1 so then whenever we come over here to this background and we put those on top you can see that this gets all washed out so whenever that's trying to pre multiply on top of the background it can't fully because the number is wrong now what we can do is basically hold this calculation off by adding an unpromoted before the grade so I'm going to hit the tab key and add an unprecedented yet we don't want to pre multiply it because we are going to unpromoted I then color correct it and then after the color correction but before the merge is where you want to add a pre-molded so now I'll put that in and you can see that now my background is unaffected by that grade node and that's what you want you don't want your background to ever be affected by any color Corrections you do to the foreground now if I would have come in and just done a little bit of an offset might not have been as noticeable if I come in here and I disabled both the pre molt and unfree mold this you know you really can't see a huge change until you crank it way up so you have to be careful that you don't make just some tiny little changes not add your promote on your unpromoted up with this issue now another issue that people do sometimes I'm going to crank that off set up again is they only add a pre molt after their color correction so let's kind of see what the difference is because this looks pretty good it's not affecting my back ground and my dragon himself you know even though I have the gamma turned up way higher than I would normally want to he looks pretty good and no matter what I come in here and change or do really we we get up only and a result on the foreground we're not affecting the background at all so I can kind of start to see an issue though if I get in a little bit closer maybe like in this area here or here or especially in this area where it's semi-transparent so let's see what happening basically by pre-multiplying this twice because its nose to pre-multiply it the first time then when we add another promote in what we get is this area becomes darkened so I'm going to add in my unpromoted and place that here so you can see the difference major difference in that coloration there if I select the unpromoted and I disable it you can see that there is a big difference in the darkness that we get in those areas there and that is incorrect you do not want that dark area to be a halo around your image so you want to make sure that you unfree moult do your color correction and then pre multiply again now I probably wouldn't want to do a color correction this crazy so I'll go in and revert my knobs and maybe just do something a little bit more subtle maybe something just kind of like this so very very slight little changes and maybe come in here and color pick my black and white point do something like that now that looks much better for him overall and you can see how nice that looks with the unpromoted the pre mold now you don't have to add these two nodes to get the same effect it's easier for a beginner as I'm showing you these two nodes here and just use those you can see the workflow you can see kind of the flow of your node graph but we actually have a control that will do this for us inside of the grade node so I'm going to just X out of those unpromoted pre Moulton loads and I'm going to disable them so we only have our grade and I'll go ahead and turn the gamma up a little bit again just so you can see that big issue we were getting with the background and what you want to do is go into this little area here where it says unpromoted by and just change that to your alpha so that is telling it I want to unpromoted I and then pre multiply and that will give you the same result as leaving that at none and having both of those nodes there so you can do either way but you don't want to do both you would just want to use both of these nodes or use neither and unpromoted by your alpha either one of those will work now you can also have this option available with color correct so instead of grade you know you might be adding some sort of a color correct and put this in here maybe say crank up your saturation or your gain something like that and I'll go ahead and fix that one but you can see that my my color correct might still be giving me some issue so in my color correct node you don't see one of those unpromoted on the color correct tab you'll actually want to go into the ranges tab and right here where you see unpromoted buy you can choose alpha and that's going to fix any issues you might get around the edge from a color correction so now I've got both of those guys in there and they're both being unpromoted lied and then premultiplied again after the color correction or grade now this color correct is a little out there so I'm going to disable that and let's just bring that back down so that we get a nice of much nicer color on our gamma perfect so hopefully that helps you with your color correction workflow remembering to either unpromoted within the note itself or add an unpromoted before your color correction and then pre multiply again afterwards never pre multiply twice and make sure that you're fixing any kind of affectations of your background by using this special unpromoted pre multiplication workflow so thank you so much for watching this tutorial on the digital tutors blog and be sure to check back again for more free tutorials
Info
Channel: Pluralsight Courses and Tutorials
Views: 99,394
Rating: 4.9276161 out of 5
Keywords: Digital-Tutors, Compositng, premult, Professional, Visual Effects, compositing, CINEMA 4D, NUKE, motion graphics, Composite, Pluralsight, unpremult, Training, VFX, Tutorial
Id: TK0I5e5cXZo
Channel Id: undefined
Length: 16min 11sec (971 seconds)
Published: Tue Nov 25 2014
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.