For a while now I have been trying to find a good workflow for manipulating depth of field in Max. I recently stumbled upon one that I feel is very useful for giving the user maximum control over his/her output. It provides more flexibility than just relying upon a flat Depth elements pass and it also fixes a few issues I was personally having with rendering out correct particles. Usually in Max to get Z Depth pass, you would render through the elements tab found in the (F10) render set up tab seen below.
Elements Tab Found in the Render Setup Rollout (F10)
This is also the practice that up until recently I have been using. Recently however, I have been integrating more animation work into my workflow and with that comes a reliance upon flexibility and feedback. Rendering out to the elements tab of a render often pushes passes into a secondary priority and something that you do to supplement perhaps the beauty pass, or another process. It also means that a lot of the time you are left waiting for the Z Depth pass due to the rendering time needed for the primary image. What I have taken to doing instead is making the Z Depth a primary pass. Doing it in this way ensure that it not only renders a lot faster, but that you also have maximum control over it. To do this I have applied a standard material across the entire scene with a distance blend falloff in the diffuse and self illumination slots of the material (Shown below).
Falloff Distance Blend Material Example
Once you have this material applied to everything in the scene (You can put it in the material override slot in the processing tab) as a distance blend falloff. You can either set it to the Z axis, or you can select object and pick the camera. Once this is done you need to make sure that your Indirect Illumination, Exposure and lights are all turned off. You also want to make sure that your sampling settings are off as well. The easiest way to do this is just to change the renderer to Scanline and turn it off. This is important in a Z Depth pass, because otherwise you might get conflicting information regarding depth information around the edges of objects as the AA attempts to soften them. What you will be left with is a pretty ragged output, so the common work around for this is to render your Z Depth pass at double the usual resolution. What this will do is provide 4x the amount of pixels for the render to attribute to the image, increasing it’s quality. You should if you did everything correctly, get something like below:
Finished Z Depth Pass rendered at 3840×2160 (Render time 10 seconds)
Bonuses of using this technique:
- You can animate both the min and max distances.
- You can edit the curves for the material.
- Sometimes the render elements ZDepth pass can cause issues with particles.
- Very quick and provides just the Z Depth output.