Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix out of date comment about depth buffer #9800

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions tutorials/shaders/advanced_postprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@ Once defined, the depth texture can be read with the ``texture()`` function.
possible when reading from the current viewport. The depth texture cannot be
accessed from another viewport to which you have rendered.

The values returned by ``depth_texture`` are between ``0.0`` and ``1.0`` and are nonlinear.
The values returned by ``depth_texture`` are between ``1.0`` and ``0.0`` (corresponding to
the near and far plane, respectively, because of using a "reverse-z" depth buffer) and are nonlinear.
When displaying depth directly from the ``depth_texture``, everything will look almost
white unless it is very close. This is because the depth buffer stores objects closer
to the camera using more bits than those further, so most of the detail in depth
buffer is found close to the camera. In order to make the depth value align with world or
black unless it is very close due to that nonlinearity. In order to make the depth value align with world or
model coordinates, we need to linearize the value. When we apply the projection matrix to the
vertex position, the z value is made nonlinear, so to linearize it, we multiply it by the
inverse of the projection matrix, which in Godot, is accessible with the variable
Expand Down