Skip to content

Add note about reverse z and update post processing doc to work with reverse z #9218

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

Merged
merged 1 commit into from
Apr 13, 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
9 changes: 7 additions & 2 deletions tutorials/shaders/advanced_postprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,21 @@ of the screen. This is why the QuadMesh needs to have height and width of ``2``.
Godot handles the transform from model to view space to clip space behind the scenes,
so we need to nullify the effects of Godot's transformations. We do this by setting the
``POSITION`` built-in to our desired position. ``POSITION`` bypasses the built-in transformations
and sets the vertex position directly.
and sets the vertex position in clip space directly.

.. code-block:: glsl

shader_type spatial;

void vertex() {
POSITION = vec4(VERTEX, 1.0);
POSITION = vec4(VERTEX.xy, 1.0, 1.0);
}

.. note:: In versions of Godot earlier than 4.3, this code recommended using ``POSITION = vec4(VERTEX, 1.0);``
which implicitly assumed the clip-space near plane was at ``0.0``.
That code is now incorrect and will not work in versions 4.3+ as we
use a "reversed-z" depth buffer now where the near plane is at ``1.0``.

Even with this vertex shader, the quad keeps disappearing. This is due to frustum
culling, which is done on the CPU. Frustum culling uses the camera matrix and the
AABBs of Meshes to determine if the Mesh will be visible *before* passing it to the GPU.
Expand Down