Choose your operating system:
Windows
macOS
Linux
DepthFade
The DepthFade expression is used to hide unsightly seams that take place when translucent objects intersect with opaque ones.
Item |
Description |
|
---|---|---|
Properties |
||
Fade Distance |
World space distance over which the fade should take place. This is used if the FadeDistance input is unconnected. |
|
Inputs |
||
Opacity |
Takes in the existing opacity for the object prior to the depth fade. |
|
FadeDistance |
World space distance over which the fade should take place. |
Network (Click for full size)
PixelDepth
The PixelDepth expression outputs the depth, or distance from the camera, of the pixel currently being rendered.
This expression supports positive values, and not negative ones. This is because the renderer relies on the Conservative Depth optimization to maintain good performance on modern hardware. This has the added benefit that if depth can move away from the camera, hardware depth rejection can be reused from the vertex shader output. Otherwise, allowing pixel depth offset to move towards the camera could cause objects to poke through anything, and the pixel shader would have to run the pixel shader for all pixels regardless of whether they are occlude without pixel depth offset or not.
In this example, the material network has been applied to the floor. Notice how the linear interpolation blends between the two colors as the floor recedes beyond 2048 units. A Power expression was used to boost the contrast between the two colors and yield a more meaningful visual result.
SceneDepth
The SceneDepth expression outputs the existing scene depth. This is similar to PixelDepth, except that PixelDepth can sample the depth only at the pixel currently being drawn, whereas SceneDepth can sample depth at any location.
Only translucent materials may utilize SceneDepth.
Item |
Description |
|
---|---|---|
Inputs |
||
UVs |
Takes in UV texture coordinates used to determine how the depth "texture" is sampled. |
In this example, we have applied the material network to a translucent sphere. Notice how the SceneDepth node is reading the pixels behind the sphere, rather than the ones on its surface.
The resulting normalized depth is linear in the 0.0 to 1.0 range.