Join Rob Garrott for an in-depth discussion in this video 035 Creating depth of field in After Effects and C4D, part of Design in Motion.
- View Offline
Hi! Rob Garrott here and welcome to Design in Motion, the weekly series where we explore important fundamentals in the world of motion graphics. The term depth of field comes from photography and it refers to how much of an image is in or out of focus. In a camera this can be controlled with the type of lens you're using or the Aperture setting. In motion graphics though, we control it with filters, and something called a Depth Map. Let's take a look. Now here we are in After Effects and I've got a very simple composition here that illustrates, I think pretty well, the idea of depth of field, and we've got some background objects, an in-focus set of type, and some foreground objects here.
Now I have already generated a RAM Preview. I will just hit 0 on the numeric keypad to activate it. Now as you can see these white spheres drop into frame and knock over the background type and travel from the background into the foreground, and as they do, they travel into and out of focus. Now that effect is being generated here in After Effects by a very cool filter called Camera Lens Blur, and I have it applied to the adjustment layer. Let's take a look at the Effects Controls here for that. You can see that the Lens Blur filter is using a Depth Map Layer.
Now the Depth Map is this very special layer that's generated by Cinema 4D when you do your rendering, and I'll talk about the Render Settings for that in just a moment. And as you can see, it's a grayscale representation of the scene as seen from the camera, and it shows in black and white detail what is in focus and out of focus. White is fully out of focus, black is fully in focus and then the shades of gray will determine the intensity of the focus from that point forward. Now let's move over to Cinema 4D and see how that depth map was generated.
So this is the scene in Cinema 4D. I will just scrub through it so you can see what's going on here. You can see those balls knocking down the type and washing over them, and moving into the foreground. If I uncheck the Active Camera icon here, we can see what's going on here. Now these green lines here represent the zones of the camera, and I've actually prebaked this animation in the Picture Viewer. Go to the Window menu and select Picture Viewer and I've got that animation there. I will hit Play and let it cache through.
Now as you can see, these balls are traveling from one zone through the central zone into a third zone, and those zones define the focus of the camera. Let's close up the Picture Viewer here and take a look at that. So here we are back in the Perspective View, and if I select my camera, the basic depth of the scene is controlled by something called a Focal Plane. And if I go to the Object Properties, that Focal Plane is defined by the Focus Distance, and I can scrub that value in or out, and you can see those values moving.
Now I've got three planes here; there is a foreground plane, the mid- ground plane, and the background plane here. This foreground plane and the background plane are defined in the Detail section. If I uncheck the Depth of Map Front Blur, the foreground plane goes away. If I uncheck the Depth of Map Rear Blur, the background plane goes away. These values represent a gradient; 0 being the start of the camera, and 366 units representing this plane right here. So from this point to this point is a transition zone, or a gradient, and that gradient represents 100% blur to no blur, and then we get a area that is 100% in focus, and then transitioning backwards from that, we get another gradient that tells us that everything from this point forward should get blurry into the distance.
That's the first part of setting up the depth of field, is activating the settings on the camera. The next part is in the Render Settings. I will hit Command or Ctrl+B to bring up those settings, and if we look at the Render Settings, I've activated the Depth Map under the Multi-Pass Settings. Now that Depth Map doesn't have any settings on it at all. You can see this area is blank even though I have it selected. All you have to do is make sure that you have that Depth Map activated when you render out your multi-pass image. If you've saved out your After Effects Compositing file correctly, using these settings here on the Save Image page under Compositing Project file.
When you move over After Effects, in your scene file, when you import it, you will have these passes. Let's move over to the depth of field- START composition and these are just the basic layers without the blur added to them. Now we don't have to get into how to use object buffers, that's covered in other courses in the library. What I want to talk about here is the Camera Lens Blur filter. So I normally use that on an adjustment layer. So I go to the Layer menu and select New > Adjustment Layer, and on that adjustment layer, I'm going to go to Effect > Blur & Sharpen > Camera Lens Blur.
Initially, the entire image gets blurry, and that's because the Camera Lens Blur filter doesn't know what layer to use as the Depth Map. Now we haven't added the Depth Map into the scene, so let's raise this up just a bit, and go back over to the Project window, and take this Depth Map and drag it in and we'll put it down at the bottom. It doesn't need to be visible in the scene, it just has to be in the composition, and so I'll drop it here at the very bottom. I typically always put my Depth Map at the very bottom of the comp, and now we can go back to the layer controls for the Adjustment Layer 3.
I need to tell the Lens Blur filter what layer to use as the Depth Map, and that is the layer 10. So I select the Blur Map Setting, and I highlight Layer 10 DOF_depth.mov. When I do that, instantly, the in-focus layer becomes in focus, and that's because it's now using that gradient to define what areas of the image are in focus and out of focus. If I go to the Blur Radius setting, and I highlight this, and scrub it in and now you can see that I can really accentuate that depth of field, and blur out those settings.
Now there are some issues with that, and that's because we're applying it to these layers here as set with object buffers. Now you can correct this by putting everything inside of a single comp and then running it on that, but there are limitations in there and typically, you'll get this kind of bleeding. So you want to be careful about how you use it here. Now I will say this, the depth of field that Cinema 4D generates using the physical render engine inside of the application is far superior to the Camera Lens Blur. The disadvantage is that, that lens blur is burned into your 3D rendering, and that if you don't like it, you have to go all the way back to Cinema 4D and re-render your entire image.
So if your rendering took nine hours, you'd have go back and re-render it every single time you wanted to change that depth of field. The advantage to this, even though it doesn't look quite as good is that you have flexibility. Depth of field can be a great tool for telling your viewer what's important within your flame, and with the right Depth Map from Cinema 4D, you'll have total control over that effect in After Effects. For more on working with renders in After Effects, check out my course Cinema 4D: Rendering Motion Graphics for After Effects, here on lynda.com. That's it for this edition of Design in Motion. Keep it moving and I will see you next time!
- Communicating emotion using color correction
- Using expressions to control animation
- Rendering type in a seamless environment
- Doing more with less in the After Effects render queue
- Creating bouncing animated type using dynamics
- Creating realism with Global illumination
- Working with Xrefs to simplify the workflow