Depth Expressions

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.

Before Depth Fade

After Depth Fade

Network (Click for full size)

PixelDepth

The PixelDepth expression outputs the depth, or distance from the camera, of the pixel currently being rendered.

PixelDepthExample.png

Result

Network (Click for full size)

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.

SceneDepthExample.png

Result

Network (Click for full size)

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.

Tags