![]() |
![]() |
![]() |
Depth, dust, and P Position
This tutorial shows how to create Z Depth, dust, and Object Position masks that can be used in a compositing package to layer shading effects such as depth of field, dirt, dust, or snow. They use a combination of Arnold shaders such as utility, range, and state_float. Thanks to Slava Sych for the assistance with this tutorial.
A scene file can be found here.
Create a state_float shader. Set the variable parameter to ray_length (Rl).
Create a range shader and connect the state_float shader output to the input of the range shader. Change the following parameters of the range shader:
Note: Note that this mask directly depends on the distance from the camera.
Create a utility shader. Set the following parameters for the utility shader:
Create a range shader and connect the utility shaders Output.G to the input of the range shader. Enable smoothstep and control the mask position with the input_min/max parameters.
If you cannot connect a single out color (Out G) to an Input in your DCC, use a rgba_to_float (mode G) shader to convert it.
Create a utility shader. Set the following parameters for the utility shader:
Create a range shader and connect the utility shaders Output.G to the Input of the Range shader. Enable smoothstep and control the mask position with the input_min/max parameters.
If you cannot connect a single out color (Out G) to an Input in your DCC, use a rgba_to_float (mode G) shader to convert it.