C

Disable Depth Test

This page describes the Disable Depth Test property of Layers edited in Qt 3D Studio.

The Disable Depth Test property can be used to simultaneously override depth testing and the order objects are rendered. The operation of this property is not as obvious as many of the other properties in the system so this page offers some insight into when, where, and why this property might be used.

What Does It Do?

By default, the Disable Depth Test property is unchecked (false). This is the normal mode of operation. In this mode rendering is done in two passes. First, reading and writing from the depth buffer is enabled and all opaque objects are rendered from front to back (objects closer to camera are rendered first). In the second pass, writing to the depth buffer is disabled and all transparent (non-opaque) objects are rendered from back to front.

The first pass allows for optimal z-culling for normal opaque 3D objects and the second pass allows for correct blending of transparent objects.

By checking the Disable Depth Test property - setting it to true - a different single pass rendering mode is enabled for the Layer. In this mode the depth buffer is not used at all, and all objects are rendered in a single back to front pass.

Why?

Each setting for this property has pros and cons.

Disable Depth Test: false

Pros:

  • This mode ensures the best visual quality because the two pass rendering technique enables the correct rendering of overlapping and intersecting 3D objects as well as correct blending of transparent objects.
  • Performance can be higher in this mode if there are opaque objects which occlude other objects. Skipping the rendering of pixels which are hidden behind fully opaque objects is a common and powerful 3D rendering optimization known as z-culling.

Cons:

  • The two pass rendering technique can be more expensive in some scenarios.

Disable Depth Test: true

Pros:

  • This mode can increase performance if there are very few (or no) objects benefiting from z culling. In cases with little overlap it can be faster to render with the one pass technique.

Cons:

  • In some scenarios, rendering errors may be introduced and/or performance can suffer in this mode. When objects intersect or overlap each other depth testing and the two pass rendering technique are necessary to achieve the correct results. (For more details, see "Painters Algorithm" on Wikipedia.

Conclusion

The Disable Depth Test property on Layers is an advanced property that can be used to increase performance under certain specific scenarios. It can be activated per-Layer to enable a separate one pass rendering technique that can achieve higher performance than the default rendering technique by eliminating the overhead of doing expensive depth testing in cases where 3D objects do not overlap or intersect.

This property should be enabled with some care. Though it is possible to increase performance by enabling this property on some Layers it is also possible to introduce undesirable rendering errors and even in some cases adversely affect performance. Remember to measure thoroughly when optimizing.

Available under certain Qt licenses.
Find out more.