Skip to content

Commit f406ec0

Browse files
committed
Document that disabling depth testing disables depth write as well
1 parent 6a7741a commit f406ec0

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

programming/render-attributes/depth-test-and-depth-write.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ used for rendering things like heads-up displays, which have no relation to the
5454
nodePath.set_depth_test(false); // Disable
5555
nodePath.set_depth_test(true); // Enable
5656
57+
.. note::
58+
59+
Disabling the depth-test with ``setDepthTest(False)`` also implicitly
60+
disables depth-writes, regardless of the current depth-write setting. This
61+
is because the graphics hardware ties both behaviors to the same comparison
62+
function: turning the comparison off disables writes as a side effect. If
63+
you want geometry to continue writing to the depth buffer while ignoring
64+
the existing depth values, leave depth-test enabled and instead use
65+
``DepthTestAttrib`` with ``M_always`` (see below), which always passes the
66+
test but still allows depth-writes to occur.
67+
5768
One can remove these settings using :meth:`~.NodePath.clear_depth_test()` and
5869
:meth:`~.NodePath.clear_depth_write()`.
5970

@@ -96,6 +107,12 @@ the following variants:
96107
nodePath.set_attrib(DepthTestAttrib::make(RenderAttrib::M_not_equal));
97108
nodePath.set_attrib(DepthTestAttrib::make(RenderAttrib::M_always));
98109
110+
The ``M_none`` mode is equivalent to calling ``setDepthTest(False)`` and, as
111+
noted above, disables depth-writes as well. To keep depth-writes active while
112+
having the depth test unconditionally pass, use ``M_always`` instead: this
113+
configures the comparison to succeed for every fragment, so the depth buffer
114+
will still be updated if depth-write is enabled.
115+
99116
Depth Sorting
100117
-------------
101118

0 commit comments

Comments
 (0)