Skip to content

Commit ce8f5ae

Browse files
authored
Merge pull request #9218 from clayjohn/reverse-z
Add note about reverse z and update post processing doc to work with reverse z
2 parents 734d4be + a6a976b commit ce8f5ae

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tutorials/shaders/advanced_postprocessing.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,21 @@ of the screen. This is why the QuadMesh needs to have height and width of ``2``.
4141
Godot handles the transform from model to view space to clip space behind the scenes,
4242
so we need to nullify the effects of Godot's transformations. We do this by setting the
4343
``POSITION`` built-in to our desired position. ``POSITION`` bypasses the built-in transformations
44-
and sets the vertex position directly.
44+
and sets the vertex position in clip space directly.
4545

4646
.. code-block:: glsl
4747
4848
shader_type spatial;
4949
5050
void vertex() {
51-
POSITION = vec4(VERTEX, 1.0);
51+
POSITION = vec4(VERTEX.xy, 1.0, 1.0);
5252
}
5353
54+
.. note:: In versions of Godot earlier than 4.3, this code recommended using ``POSITION = vec4(VERTEX, 1.0);``
55+
which implicitly assumed the clip-space near plane was at ``0.0``.
56+
That code is now incorrect and will not work in versions 4.3+ as we
57+
use a "reversed-z" depth buffer now where the near plane is at ``1.0``.
58+
5459
Even with this vertex shader, the quad keeps disappearing. This is due to frustum
5560
culling, which is done on the CPU. Frustum culling uses the camera matrix and the
5661
AABBs of Meshes to determine if the Mesh will be visible *before* passing it to the GPU.

0 commit comments

Comments
 (0)