Keep up-to-date with Free tutorials!!


Sign up to our twice-monthly newsletter today for the latest tutorials, interviews and product information.

Sign me up to receive third-party emails from 3dtotal's partners, too!

- Latest news
- Exclusive Shop Offers
- Preview early content
- Plus much more


Not Ready to take that step? OK, Why not just Subscribe to the RSS Feed

submit tutorial
1 | 2
ZDepth and height GrayScale Representation

| Your Rating:
rating star nonerating star nonerating star nonerating star nonerating star none
(Score 0 out of 5 after 0 Votes)
| Comments 0
Date Added: 9th December 2009
Software used:

7. Now delete the 3 connections you've just created by selecting them and hitting del on your keyboard (remember this trick was done only to make the input[3D] parameters of the plusMinusAverage node appear in the connection editor). Now select them both (the plusMinusAverage and the multiplyDivide), and go to Window -> Connect selected. Connect the OutputX, OutputY and OutputZ respectively to Input3D[0].Input3Dx and Input3D[1]. Input3Dx, Input3D[2]. Input3Dx.

8. To calculate the square root of the sum, create another multiplyDivide node, and connect the Output 3Dx of the plusMinus Average node, to the Input 1 of the multiplyDivide node. In its Attributes, choose Power as operation, and set the value of x in 'Input 2' to 0.5.

9. The output of the last multiplyDivide node we've created is the distance from the sampled point to the camera. And since the u or v values of the ramp can only take values between 0 and 1. So, create a Set Range node, select the second multiplyDivide node, shift select the Set Range node, and go to Window -> Connect selected. Connect the OutputX of the former, to ValueX of the latter. In the Set Range node Attributes, set the Min to 0, the Max to 1, the Old min to 0 and let the Old max represent the distance beyond which objects become invisible, so in our case, the distance from our camera to the farthest sphere.


10. Now you can use the output of the setRange node to choose between points of a ramp. Map the color of your objects material with a ramp. In the Create render node, make sure that Normal is selected, and choose ramp. Choose black and white for the colors of the ramp. Connect the Output X of the set range node to the UCoord of the ramp node. Make sure that your ramp is a U ramp. (You might need to invert its white and black colors, depends on your case.)

11. This method gets over the problems that we faced with the first one.

Third Method

12. You can also use scripting to obtain the same result of the second method. For this, you need a sampler info node, and a material. Map the color of the material with a ramp, choose normal, and choose a grayscale ramp as before.

13. In the Expression Editor, write the expression that calculates the RMS, which is the following code line (in my case my sampler info node is samplerInfo1):

$distance = sqrt ( pow (samplerInfo1.pointCameraX,2)

+( pow(samplerInfo1.pointCameraY,2)

+(pow (samplerInfo1.pointCameraZ,2));

Set a maximum value which is equivalent to the old max used in the second method, and divide the distance by this max value, for example let it be 56. Then you will have to link the obtained value the ramp's V coordinate (make sure your ramp is a v ramp in this case).

$MaxValue= 56;

ramp4.vCoord = $distance / $MaxValue;

Click on create to create your expression, and render the scene. You should obtain the same result as before.

The above methods can serve for many other uses. For example to create a height field, you have to choose the Point world Y attribute instead of the Point camera attribute, inside the sampler info node attributes.

For a video version of this tutorial, here is a direct download link (i.e. you don't have to pay or to wait to download the file):

For any questions or suggestions don't hesitate to contact me.

< previous page

1 | 2
Related Tutorials

Introduction to rigging in Maya – The hands

by Jahirul Amin
published on 2014-03-17

Keywords: Maya, Rigging, Animation, Hands, Arms, Shoulder, Character

rating star fullrating star fullrating star fullrating star fullrating star full (14)
Comments 0 Views 57610

Create photorealistic cars in Maya

by Alexandr Novitskiy
published on 2016-05-13

Keywords: cars, Maya, tutorial

rating star fullrating star fullrating star fullrating star fullrating star half (6)
Comments 0 Views 12130

Know the Basics: Maya Part 1: Interface

by Paul Hatton
published on 2016-10-13

Keywords: Maya 2017, Tutorial, Basics, Interface, Maya

rating star fullrating star fullrating star fullrating star halfrating star none (6)
Comments 0 Views 11670

Sci-fi cars in Maya: Desert Racer Part 1

by Rory Björkman
published on 2017-01-12

Keywords: car, desert, racer, scifi, Rory Björkman, Maya

rating star fullrating star fullrating star halfrating star nonerating star none (5)
Comments 0 Views 5842
Readers Comments (Newest on Top)
no comments!
No comments yet. Be the first to comment!
Add Your Comment..