I’ve been trying to figure out how to make a 3D fog effect in After Effects for a while. Here’s one way to do it. WARNING! It’s a bear. It will slow down your renders quite a bit, and it’s probably most useful as a “final pass” effect.
Here’s how it works:
There are 256 duplicate “Fog Layer” compositions each containing a semitransparent solid, spaced slightly apart from one another on the Z axis, like a stack of cards.
There is a “Fog Null” in the same position as the frontmost of the 256 compositions, with all 256 Fog Layer comps being parented to this null. That way, the scale on the Fog Null’s Z-axis can be used to control the depth of the fog. The Fog Null’s X and Y axis scale can be used to increase or decrease the size of the Fog Layers.
The Fog Null is parented to the camera, so that wherever the camera looks, the depth of the fog will be consistent from the location of the camera.
How to set it up:
I would recommend that you start your project with the example file, since it’s all set up. If you need to add the fog to your existing file, here’s how to do it:
Add the entire contents of the “Fog Comp” to your main comp. Copy the position, point of interest, and rotation keyframes from your current camera to the “Camera 1″ of the Fog Comp so that the two cameras share identical positions. You can then use the Fog Comp’s camera as your main camera, or you can parent the Fog Null to your camera and get rid of the camera from the Fog Comp.
If you don’t need 256 levels of variation in your fog, you can delete some of the Fog Layers. If you only need 16 layers of fog, delete layers 17-256. Deleting these layers will speed your rendering time greatly. I would strongly recommend this. 256 layers of detail in your fog is probably overkill for most purposes.
You will then need to set the depth of the fog. Go into the Fog Layer comp and increase the opacity of the solid inside to 100%. Next, temporarily hide all but the furthest Fog Layer.You can then adjust the scale on the Fog Null’s Z-axis to set the farthest point of your fog.
Next, make sure the Fog Layers are big enough to fill your image with fog. Use the X and Y scale on the Fog Null to make sure that the edges of the furthest Fog Layer won’t show up in your image.
You can then un-hide your other fog layers. Don’t forget to turn the opacity back down on the solid inside your Fog Layer comp, or all your Fog Layers will be opaque and you won’t be able to see a thing.
By going into the Fog Layer comp, you can increase or decrease the transparency of the solid it contains. This will alter the thickness of the fog. You can also adjust the color of the solid with Effect->Color Correction->Hue/Saturation to give the fog a color. You can also add any image or movie into this comp, and it will become the image used to create the fog.
Make a Z-depth channel of your 3D After Effects project
You can use this technique to make a Z-depth channel for your 3D layers.
First, make all your 3D layers white. Use Effect->Color Correction->Hue/Saturation and set the “Master Lightness” to “100″ for each layer.
Next, adjust the opacity of your fog so that the furthest point appears totally black. To do this, go into the Fog Layer comp, and use Effect->Color Correction->Hue/Saturation to make the solid black. Then carefully increase the opacity of the solid until the furthest point in your image is totally black.
You should now have a greyscale image representing the depth of your comp.
Let me know how it goes!