
1. Z Depth With Mental Ray
Step 1
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.
Step 2
I have added and positioned several Omni lights in the scene. I have chosen Ray Traced Shadows as shadow type.
Step 3
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.
Step 4
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.
Step 5
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.
Step 6
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.
Step 7
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.
Step 8
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.
Step 9
To measure the distance, I need a tape. So, go to Helpers > Tape and draw a tape from the camera to the closest sphere.
Step 10
Pick the tape’s head and you will get its value. This is the Z Min value.
Step 11
Put the value in Z Min box.
Step 12
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.
Step 13
Put this value in Z Max box.
Step 14
Press
F9 to render the frame. Now you will
get a perfect Z Depth pass along
with the Diffuse pass.
2. Z Depth through MAXScript
Step 1
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.
Step 2
Download and install the script. Normally you have to put the script into the Scripts folder of the 3ds Max root directory.
Step 3
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.
Step 4
Click on Pick and Select Camera button. Press H to open the Pick Object window and here select the camera.
Step 5
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.
Step 6
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.
Step 7
Once you are satisfied with the preview, click on Render VFB button. This will show you the final result.
3. Compositing
Step 1
Open both the Diffuse and Z Depth pass renders in Photoshop.
Step 2
With the Z Depth layer selected, press Crtl-A button to select the entire image and then press Ctrl-C to copy the image.
Step 3
Now deselect the Z Depth layer and select the Diffuse layer. Then go to Channels tab.
Step 4
In the right side corner, click on the drop down arrow menu and select New Channel from the list.
Step 5
It opens the New Channel window. Give it a name, such as Alpha 1.
Step 6
With the Alpha 1 channel selected, press Ctrl-V to paste the copied Z Depth image.
Step 7
Go to Layer panel once again. Now, with the Diffuse layer selected, go to Filter > Blur > Lens Blur.
Step 8
It opens the Lens Blur window. The image look totally blurred and out of focus right now.
Step 9
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.
Conclusion
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.
Subscribe below and we’ll send you a weekly email summary of all new 3D & Motion Graphics tutorials. Never miss out on learning about the next big thing.
Update me weeklyEnvato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!
Translate this post