1. Z Depth With Mental Ray
I have made a very simple scene for the demonstration. This scene contains several spheres. I have also applied some materials and set the rendering engine to Mental Ray. I have set a camera also.
I have added and positioned several Omni lights in the scene. I have chosen Ray Traced Shadows as shadow type.
Press the F10 key to open the Render Setup window. In the Renderer tab, set the Minimum value to 4 and the Maximum value to 16. Select Mitchell for the Filter Type.
Now render the scene. It looks nice, but the depth is still missing. I can enhance the overall look by adding a Z Depth pass while compositing.
In general words, a Z Depth pass is a grayscale image, similar to the alpha channel for the graphical representation of depth. In a Z Depth pass, every pixel in a scene is assigned a 0-255 grayscale value based upon its distance from the camera.
The objects closest to the camera are white and the objects furthest from the camera are black. It gives an extra sense of depth and realism after compositing. Look at the image below for a before and after comparison.
See how I generate a Z Depth pass using Mental Ray. Press the F10 key to open the Render Setup window. In the Render Element tab, click on Add button and choose Z Depth from the list. Click on OK.
Press F9 to render the frame. You can see a grayscale Z Depth pass. The objects closest to the camera are white and the objects furthest from the camera are black.This is not the correct Z Depth pass as I don’t know the exact distance between the camera and the objects in the scene.
To know the exact distance between the camera and the objects, Z Min and Z Max values will help. Z Min defines the distance between the camera and the closest object. And Z Max defines the distance between the camera and the furthest object.
To measure the distance, I need a tape. So, go to Helpers > Tape and draw a tape from the camera to the closest sphere.
Pick the tape’s head and you will get its value. This is the Z Min value.
Put the value in Z Min box.
Pick the target of the tape tool and put it beside the furthest sphere from the camera. Pick the tape’s head and you will get the Z Max value.
Put this value in Z Max box.
F9 to render the frame. Now you will
get a perfect Z Depth pass along
with the Diffuse pass.
2. Z Depth through MAXScript
Michele Marcelli has written a very useful script for creating Z Depth. You can go to www.scriptspot.com to obtain the script. The best thing about it is that the script is free to use.
Download and install the script. Normally you have to put the script into the Scripts folder of the 3ds Max root directory.
Back in 3ds Max, go to MAXScript > Run Script. This opens the browser, select the script and click on Open. This opens the script’s window.
Click on Pick and Select Camera button. Press H to open the Pick Object window and here select the camera.
Click on Preview Z-Depth (Selected Camera) button. Within a couple of seconds, you will see a preview of Z Depth pass in the preview window. The output result looks good, but a bit grainy. So I need to tweak some values.
You can play with the Z Min and Z Max values to get the desired Z Depth pass. Each and every time you need to check the pass clicking on the preview button.
Once you are satisfied with the preview, click on Render VFB button. This will show you the final result.
Open both the Diffuse and Z Depth pass renders in Photoshop.
With the Z Depth layer selected, press Crtl-A button to select the entire image and then press Ctrl-C to copy the image.
Now deselect the Z Depth layer and select the Diffuse layer. Then go to Channels tab.
In the right side corner, click on the drop down arrow menu and select New Channel from the list.
It opens the New Channel window. Give it a name, such as Alpha 1.
With the Alpha 1 channel selected, press Ctrl-V to paste the copied Z Depth image.
Go to Layer panel once again. Now, with the Diffuse layer selected, go to Filter > Blur > Lens Blur.
It opens the Lens Blur window. The image look totally blurred and out of focus right now.
Select Alpha 1 as the Source channel and set the Blur Focal Distance to 255. Now you will see an extra realm of depth in the scene as some part of the image gets blurred partially and rest of the part remains in focus. This happens due to the Z Depth pass. You can easily control the amount of the focus and area of focus with the parameters of the lens blur effect.
I hope you have enjoyed these ways to create Z Depth pass in 3ds Max. The script written by Michele Marcelli is the fastest way to get the Z Depth pass. The script is totally free to use, however if you find it useful, you can donate an amount to the creator of the script as a return gesture. This is only a matter of choice.
Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!Translate this post