Ready to watch this entire course?
Become a member and get unlimited access to the entire skills library of over 4,987 courses, including more 3D + Animation and personalized recommendations.Start Your Free Trial Now
- View Offline
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.
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 up the viewer brightness so you can see it better--and the background layer, which we can 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 all the layers we want are coming right from here, we can hook up the B input to there, 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 the D 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 Filter tab, 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 do your 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 particular case 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 do it 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 the alpha 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 see the 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, so I 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 the focus 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 it are 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 of field or out of it, in front or behind.
The green color is the part that's within them the depth of field, in other words, 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 the camera, 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 is working. We'll turn it off to, go back to our image, because normally you're going to 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 limits the 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, but less 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 see that 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 focus and 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 how that works, let's push into this part over here. The filter shape parameter adjust the look of the softening. 0 gives you a Gaussian filter and 1 gives you a disc filter, so you would just dial this for the 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 the Merge 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.
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®.
- Exploring NukeX
- Working with the new paint tools
- Using the Clone and Reveal tools
- Reviewing the Keylight matte controls
- Creating Keylight holdout and garbage mattes
- Performing multipass keying
- Working with mattes in Ultimatte
- Creating specialized keys
- Drawing and warping splines
- Exploring the MotionBlur2D and ZBlur nodes
- Navigating the Dope Sheet
- Making gizmos