Join Ian Robinson for an in-depth discussion in this video Creating depth mattes, part of After Effects Guru: Working with Photoshop Files.
- View Offline
Now I know we've all been in that situation where somebody's given you a piece of footage or an element, and they've asked you to recreate something that frankly should've been done in the original production. This is one of those effects that can bail you out. Basically what we're going to be doing is taking a flat image, and then animating a gradient that will create depth of field. So we'll create a rack focus virtually in After Effects based on the matte that we'll create in this video here, so let's get started.
Notice I've got this huge layer here. Now of course I haven't resized this for video or anything else like that, but I do want to be able to move my camera around within this layer. And as I'm doing that, I want it to look as though the camera is moving focus from the back part of the image all the way to the front part of the image. Now there are a couple of different ways we can create this depth matte. But the way I'm going to do it is to just focus on this specific area here first. If we look at the center part of the image, you can see I've got this background building here, and it's relatively flat to the camera.
But I'm in a rather unique situation. And, and I like giving this example, because nothing is ever exactly perfect unless you shot it that way on purpose. What I mean by that, if you look at where I'm standing, when I took this photograph, I'm standing off to the right side of this alleyway. And so I'm a little closer to this part of the building. And with the wide angle lens that I was using, I'm getting much more information of this building than I am from this building.
So while most people would look at this and think that the blur would be perfectly straight going from one building to the other, since I can tell I'm kind of off angle that I want to actually have the blur be in a slightly different place on this wall than on this wall. And there will be an instance when we reach the edge of this wall, where we'll still be able to see information on the right wall. To get started, let's start by actually adding a gradient.
Usually, when I go to create a gradient, I just create a new layer. So go to your Layers panel and click on the New Layer button in the bottom of the panel. Now we can go to the Gradient tool. If you click once, it should load up your gradient options on the top of Photoshop, and then I want you to click on this pull down. And this will load up a bunch of different gradients. As I was looking at this initially, the first way I want to create the gradient for the area was to create a gradient along this wall, and to create a separate gradient along this wall, and to create a separate gradient along that.
Now, since this is perpendicular to the camera, this back building, we don't necessarily need a gradient for that. But check this out. Since the top of that building continues on into basically nothingness, it really doesn't matter what else is going on here in the center of the image. If the rack focus is moving along on a perfectly clear blue gradient, you're not going to be able to see that focus happening. So, the second I thought about that, I realized I don't need to create separate layers for each individual building.
All I need to do is create one gradient where there's a black swath right here in the middle, and then everything else just emanates off to the sides. So to do that, all we have to do is double click on our gradient and that'll open the Gradient Editor. So in here I want to click on this left most little arrow and drag it towards the middle. Now notice the black area here isn't exactly in the middle of my layer. So I do want it to be offset.
Let's use a location of about 38, that's perfectly fine. Now to get another stopper, all we have to do is move our hand just a little bit below the gradient and click once, and that'll create another stop. So now we can drag that to the left. And as long as this little triangle is filled in black on top of that stop, I can go change the color. So let's click and change the color to white and click OK. So, now I have a gradient going from white, to black, to white. This is exactly what we want. So, we can click OK. And now with my Gradient tool, I can click over here on the left side, right up to the edge of that one building.
Click and start dragging to the right. Now if you hold down Shift as you drag to the right, I want you to go right to the edge of the other building and then let go. And now the black gradient should be somewhat lined up with the other building, but just to double check I'm going to decrease the opacity here. And you can see it's, it's a little offset to the right. So, what we'll do is just press Cmd+T to open our transform options. And I'm just going to bring this over to the left here a little bit, and then click OK.
So now, here I can see the left edge of that is right on the edge of that building. And this is exactly what I want. But notice I still have some extra area here for this extra wall. And I said that was going to happen when we first started talking. So let's make sure we have Layer 1 selected. And bring the opacity up to 100%. Notice that, this area here, this transition, is already at white at this point. And I don't necessarily want it to be that way. So what we'll do, is grab our selection tool, make sure that you have the Rectangular Marquee tool selected, and then click and drag around the right side of our shape.
You want to make sure to get all of it selected, and you want to make sure that the left side is at least in the dark black area. Now we can press Cmd+T, which will open up our Transforms, and we can click and drag to the right. And that will soften this gradient on the right hand side. So, now when I press Return, and press Cmd+D to deselect, you can see I've got my dark gradient here, my softer gradient on the right side, and my more sharp gradient on the left side.
This is going to create a rather interesting effect when we actually go to apply our blur. But since that left building is significantly shorter than the exposure that I have here on this right building, I think it's going to create a look that'll work perfectly well. So when it comes to creating depth mats, the thing you need to understand is the relation of the gradient of the objects in the scene. Once you actually have a gradient applied, then you can control how the depth of field is applied throughout that gradient, once that's imported into After Effects.
- Isolating still images with channels and masks
- Preparing layer groups for After Effects
- Working with layer styles and vector shapes
- Importing compositions in After Effects
- Converting Photoshop type
- Animating with layer styles and depth mattes
- Fixing video issues in Photoshop
- Creating data sets