Skip to content

Commit a3cf3cc

Browse files
committed
Add multiple renderer support to Advanced Postprocessing
1 parent c5babea commit a3cf3cc

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tutorials/shaders/advanced_postprocessing.rst

+10-5
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,23 @@ from ``0.0`` to ``1.0`` in the ``z`` direction when using the Vulkan backend.
108108
Reconstruct the NDC using ``SCREEN_UV`` for the ``x`` and ``y`` axis, and
109109
the depth value for ``z``.
110110

111-
.. note::
112-
113-
This tutorial assumes the use of the Vulkan renderer, which uses NDCs with a Z-range
114-
of ``[0.0, 1.0]``. In contrast, OpenGL uses NDCs with a Z-range of ``[-1.0, 1.0]``.
115-
116111
.. code-block:: glsl
117112
118113
void fragment() {
119114
float depth = texture(depth_texture, SCREEN_UV).x;
120115
vec3 ndc = vec3(SCREEN_UV * 2.0 - 1.0, depth);
121116
}
122117
118+
.. note::
119+
120+
This tutorial assumes the use of the Forward+ or Mobile renderers, which both
121+
use Vulkan NDCs with a Z-range of ``[0.0, 1.0]``. In contrast, the Compatibility
122+
renderer uses OpenGL NDCs with a Z-range of ``[-1.0, 1.0]``. For the Compatibility
123+
renderer, replace the NDC calculation with this instead:
124+
125+
.. code-block:: glsl
126+
vec3 ndc = vec3(SCREEN_UV, depth) * 2.0 - 1.0;
127+
123128
Convert NDC to view space by multiplying the NDC by ``INV_PROJECTION_MATRIX``.
124129
Recall that view space gives positions relative to the camera, so the ``z`` value will give us
125130
the distance to the point.

0 commit comments

Comments
 (0)