Video: The ZBlur node

The ZBlur node simulates depth of field by doing a selective blur on a 3D image based on the value of its depth.Z data. Rendering the depth of field into the 3D image directly is very expensive, and if a change is needed, it has to be re-rendered. So it's much faster to do a depth of field blur in 2D, plus it's quick and easy to change. To see how it's done, you'll need an image, so we'll fire up our Read node, select our Project Media, and get the Z Fighter.exr image. Say Open, hook it up to the viewer by typing 1.

Author Steve Wright explores the new features found in the 3D digital compositor Nuke 6. The course introduces the RotoPaint node for drawing and painting effects, the Keylight keyer for creating mattes and composites, and the SplineWarp node for warping images. The course also explains how to merge keys, animate with keyframes, and create image-based blurs. Exercise files accompany the course.

Nuke 6 New Features was created and produced by Steve Wright. We are honored to host his material in the lynda.com Online Training Library®.

The ZBlur node

The ZBlur node simulates depth of field by doing a selective blur on a 3D imagebased on the value of its depth.Z data.Rendering the depth of field into the 3D image directly is very expensive, and ifa change is needed, it has to be re-rendered.So it's much faster to do a depth of field blur in 2D, plus it's quick and easy to change.To see how it's done, you'll need an image, so we'll fire up our Read node,select our Project Media, and get the Z Fighter.exr image. Say Open, hook it upto the viewer by typing 1.

Let's get a little more viewer space.Now this EXR image has several layers in it.Our jet of course, with an alpha channel, plus a depth.Z channel--I'll turn upthe viewer brightness so you can see it better--and the background layer, which wecan use for our composite.I'll put the viewer back to the RGBA layer, and we are done with our Read node,so we can close that. So let's do the composite first, get that setup.Select the Read node and type M on the keyboard to get a Merge node. Since allthe layers we want are coming right from here, we can hook up the B input tothere, and we'll tell the Merge node that we want to composite the RGBA layers,which is our space fighter, over the BG layer, which is the background.

We don't need to see the composite until later, so I'll disable the Merge node with theD key and delete it from the Property bin.So now we can go get our ZBlur node, select the Read node, go over to the Filtertab, and click on the ZBlur node.The first thing we want to do is set the channel that are going to be ZBlurred,which will be just the RGBA channels.Next we have to tell it where to find the depth.Z information. By default,it's going to look in the depth.Z channel, which is the case with this example,so we'll leave it unchanged.

Okay, the math pop-up. There is no real industry standards yet on how to doyour depth.Z data, so you'll have to choose which methodology your particular system uses.You might have to do some experiments to figure that out. But in this particularcase the default depth map works correctly.The focus plane is the single plane where the picture is in perfect focus.The depth-of-field parameter is how deep the in-focus portion is.Size is how blurry it gets, and maximum puts an upper limit on how blurry things get.

The real key to setting up the ZBlur quickly and efficiently is to be able to doit visually based on your image, so let's push in a little bit here.We want to be able to pick the focus plane right off the image.Let's say I want this part to be the focus plane.So the first step is we're going to take the depth.Z data and put it into thealpha channel of the viewer.There. I'll turn up the viewer again so you can see it better.I'll put that back to normal and switch the viewer back to RGB.

The reason for this setup is so we can move the cursor over the image and seethe depth.Z data down here.I'll set up color sample window here, and this number down here is the depth data of our image,not the alpha channel.As I move my cursor around the screen, you can see the depth.Z data changing, soI know exactly where I am anywhere on the image.So let's say I want this part of the picture right here to be the focus plane,so I look at my depth.Z data down here in the bottom .05627, so I'll set thefocus plane to match at .056, which is close enough.

I'll zoom out a little bit so we can see the whole image.I'll tap up the size to increase the amount of blur.This is just a starting position.Okay, next, let set the depth of field.I'm going to start by setting it to .1, which is a very shallow depth of field.So things in front of it are out of focus a little bit and things behind itare out of focus a lot.Next, I would like to show you the focal-plane setup. Check this button here.This gives you a color scheme for which parts of the picture are in the depth offield or out of it, in front or behind.

The green color is the part that's within them the depth of field, in otherwords, in 100% perfect focus.If I increase that, the green zone gets larger.The focus plane is where it is front to rear, closer and further from thecamera, so if I change that, you can see it's walking at forward and backward in the picture.So the focal plane setup will allow you to visualize how your depth of field isworking. We'll turn it off to, go back to our image, because normally you're goingto dial it in visually.

Now if I increase the size to a large value, it really blurs the image.The maximum value limits how blurry it gets, so if I dial that down, that limitsthe upper size of the blur. I'll put that back to default.With the depth of field the things closer to the camera do get out of focus, butless quickly than things behind the camera. I'll show you that.Let's zoom in here. And I'll toggle the ZBlur node on and off, and you can seethat there's no change in the focus in this part of the picture.

However, back here, toggling it on and off, you can see it's really out of focusand coming forward from that, closer to the camera,it's out of focus just a little bit.One more parameter you might be interested in is the filter shape. To see howthat works, let's push into this part over here.The filter shape parameter adjust the look of the softening. 0 gives you aGaussian filter and 1 gives you a disc filter, so you would just dial this forthe look that you want-- a very subtle difference.

But then again, Nuke get all about subtlety, so we'll zoom back, reposition our viewer.So let's say we're done with our depth- of-field adjustments. We'll go back to theMerge node, turn it on, and admire the finished composite.Nuke does not have an image-based blur node like shake and others, but next,we'll see how to set up the ZBlur node to turn it into an image-based blur node.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Already a member ?

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships.
Learn more

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about lynda.com and our online training library:

new course releases

newsletter

general communications

special notices

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

new course releases

newsletter

general communications

special notices

Here’s our privacy policy with more details about how we handle your information.