View Full Version : Creating a Z-Depth pass within AE,and bokeh effects. Help please.

02 February 2010, 04:26 AM
Hi there. I have a problem thatīs giving me a headache. Im currently making an animation based off another one of the tutorials at the videocopilot site, the "3d City" one. Its been very informative and enlightening, but i also have met with a looooot of problems and bugs that make me think that if i want to do something as complex as a city in 3d, im better off doing it in a 3d software rather than in After Effects.

Anyways, given that im almost finished with the project, im not going to give up now. So basically, i have two problems.

1: I want to have a DOF effect so the city wonīt look so CG and perfect.
2: I want the bokeh effect that i see so much in movies when two characters are talking and thereīs a city in the background and you can see all this little circles of colors dancing around.

So, the first thing i tried was to enable de DOF of the camera in the After Effect project. FAIL... one of the problems that took me so hard to solve, where some buildings suddenly flashed in front of others that shouldīve been obstructing them, reappeared.So i looked for other options.

What i finally did was to order the layers of the buildings in a logical fashion in the stack, i.e., the row of buildings that were far in the background, were at the bottom of the stack, and the ones that were closer to the camera, were at the top. Between every row of buildings layers, i placed an adjustment layer (actually i did this early on to make different 3d spaces so the buildings would stop overlapping over one another). So, in those adjustment layers, i applied the "Lens Blur" effect, and i tried to cheat a "DOF" look by applying more blurriness to the bottom layers (the buildings that were fartest away) via the adjustment layers, and less blurriness the to the top layers (the buildings in the foreground) that should be in focus (oh,and i knew that the amount of blur that i applied to the top adjustment layers would "add" to the blur applied to the lower adjusment layers; i tried to adjust the values to compensate this).

So, the result of all of this was a look that was really close to what i was going for; it was not perfect, but it was enough for me. So, i rendered a test animation and... FAIL. The animation looked good to me, but the blurred highlights, the "bokeh" like thingies, were flickering very badly. I tried to use different parameters to no avail. I then searched the forums about this and a lot of people mentioned the "Frischluft Lenscare" plugin for doing this type of effects. So i downloaded a demo and did a test and the results where very similar to those of the "Lens Blur" effect of AE. The effect looks nice in a still, but when i render an animation it looks really weird.

So... i have 2 questions regarding this.

1 - Is there a way to generate a Z-Depth pass within an After Effect project so i can apply a Depth of Field Effect (be it the AE own Lens Blur or Frischluft Lenscare) without doing the messy thing i explained earlier with the bunch of adjustment layers and such? Iīve imported before .rpf files rendered from 3ds Max to AE and extracted the Z-depth succesfully, but this time all the 3d was done inside After Effects. Its there a way of doing this?

2 - Why the hell do the bokeh like highlights flicker so much when i render the animation? (whether im using "Lens Blur" or "Frischluft Lenscare") Can i get around this problem? Im not very familiarized with these kind of effects so maybe im missing something very stupid. Sorry if thatīs the case.

Oh, im working with a 16bpc project (i dont konw if thatīs relevant to my problems).

Any help would be greatly appreciated. I attached a part of the video for you to see what im talking about. Cheers.

02 February 2010, 04:44 AM
Ups, i see that the file was not attached. Anyways, you can download it using this link:

See how all the tiny spots of light (mostly the windows in the buildings) flicker so badly?

02 February 2010, 06:27 AM
1 - Is there a way to generate a Z-Depth pass within an After Effect project

- Gradients on layers
- a duplicate of the scene in gray, illuminated by a light that is in the exact same place like the camera
- Digieffects/ Buena Depth Cue

The latter has some issues in newer AE versions, though, since it hasn't been updated in eons.

2 - Why the hell do the bokeh like highlights flicker so much when i render the animation?

Sampling is based on screen coordinates, so naturally, based on your method to construct the DOF, the brightness of each pixel changes notably as the camera moves around. You are also using pretty odd settings it seems to me. It doesn't look at all "optical". The Bokeh is too small and appears in the wrong places. If it were bigger, the overlap of the individual iris shapes would cover up some of the flickering...


02 February 2010, 07:56 PM
Maybe (maybe) you could isolate the lights and blur them to reduce the flicker caused by aliasing, then levels the alpha to turn them back into hard edged circles, then apply your bokeh effect to that. That's the only way I can think of to smooth out that flicker. Otherwise, it simply has to be rendered at a much higher resolution so that those lights don't drop out when they're straddling a pixel.

02 February 2010, 08:24 PM
Hi there Mylenium, thanks (again!!!) for your help.

What you said about making a duplicate of the scene in grey and putting a light where the camera is for faking a Z-Depth pass is very very ingenious, i didnīt thought of that. I will give it a shot and see how the results compare to the method i applied. (im guessing that i have to tint all of the 3d layers in a perfect grey dont i? i.e.: R:127 G:127 B:127... and that the light should be perfect white?). Thanks a lot.

PaulDeSilva, what you say makes sense... i will try to apply that to see how it looks. The problems i have its that the project its so big and heavy now and has so many layers that making any tests and try outs is horribly slow and messy; and that i canīt render at a higher resolution, being that i planned the project to be in SD and i dont think that my textures and such would hold up in HD.

Thanks a lot for your answer too! I welcome any other tips. :)

02 February 2010, 06:36 AM
That trick with the light won't work, as apparently in AE it has no falloff. My bad. Sorry, I wasn't thinking straight. It would work in a 3D program, though. Another thing that comes to mind is creating some sort of pseudo-volumetric effect on a scene. If you stack a ton of white layers slightly spaced apart, only with a hint of opacity each, and your scene is black, the accumulated opacity of all layers will act as the depth, as apparently the black parts "cut it out". Let us know if you need more guidance.


02 February 2010, 11:16 PM
I like the light idea better. For the falloff you can try Dan Ebbert's script ( the digieffects ( Let us know how it goes.

CGTalk Moderation
02 February 2010, 11:16 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.