Depth Material Expressions

Material expressions that deal with depth of the pixel being rendered.


The DepthFade Material Expression is used to hide unsightly seams that occur when translucent objects intersect with opaque ones.



Fade Distance

World space distance over which the fade should take place. This is used if the FadeDistance input is unconnected.



Takes in the existing opacity for the object prior to the depth fade.


World space distance over which the fade should take place.

In the comparison below, a translucent sphere intersects an opaque one (green). Note the smoother transition when DepthFade is used.

Without Depth Fade

With Depth Fade

The Material network for this example is pictured below.

Depth Fade Material Graph


The PixelDepth Material 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 toward 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.

Pixel Depth Example


Material Graph (Click to enlarge.)

In this example, the Material network was 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.


The SceneDepth Material 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.




Takes in UV texture coordinates used to determine how the depth "texture" is sampled.



Material Graph (Click to enlarge.)

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.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey