Blender V5.3
eevee_reverse_z_lib.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
13#include "gpu_shader_compat.hh"
14
15namespace reverse_z {
16
17/* Needs to be called at the end of the vertex entry point function. */
19{
20 /* Remapping from -1..1 to 1..-1. The scaling to 0..1 is handled by the backend. */
21 hs_position.z = -hs_position.z;
22 return hs_position;
23}
24
25/* Needs to be called for every depth buffer read, but not for the HiZ.
26 * The HiZ buffer is already reversed back before downsample. */
27template<typename T> T read(T depth_buffer_value)
28{
29 /* Remapping from 0..1 to 1..0. The scaling to 0..1 is handled as normal by drw_screen_to_ndc. */
30 return 1.0f - depth_buffer_value;
31}
32template float read<float>(float);
34
35} // namespace reverse_z
#define T
T read(T depth_buffer_value)
float4 transform(float4 hs_position)
float z
Definition sky_math.h:225