Use Reverse Z for the depth buffer
This commit is contained in:
committed by
Rémi Verschelde
parent
f47f4a02c8
commit
d950f5f838
@ -719,7 +719,8 @@ Projection Projection::operator*(const Projection &p_matrix) const {
|
||||
return new_matrix;
|
||||
}
|
||||
|
||||
void Projection::set_depth_correction(bool p_flip_y) {
|
||||
void Projection::set_depth_correction(bool p_flip_y, bool p_reverse_z, bool p_remap_z) {
|
||||
// p_remap_z is used to convert from OpenGL-style clip space (-1 - 1) to Vulkan style (0 - 1).
|
||||
real_t *m = &columns[0][0];
|
||||
|
||||
m[0] = 1;
|
||||
@ -732,11 +733,11 @@ void Projection::set_depth_correction(bool p_flip_y) {
|
||||
m[7] = 0.0;
|
||||
m[8] = 0.0;
|
||||
m[9] = 0.0;
|
||||
m[10] = 0.5;
|
||||
m[10] = p_remap_z ? (p_reverse_z ? -0.5 : 0.5) : (p_reverse_z ? -1.0 : 1.0);
|
||||
m[11] = 0.0;
|
||||
m[12] = 0.0;
|
||||
m[13] = 0.0;
|
||||
m[14] = 0.5;
|
||||
m[14] = p_remap_z ? 0.5 : 0.0;
|
||||
m[15] = 1.0;
|
||||
}
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ struct _NO_DISCARD_ Projection {
|
||||
void set_identity();
|
||||
void set_zero();
|
||||
void set_light_bias();
|
||||
void set_depth_correction(bool p_flip_y = true);
|
||||
void set_depth_correction(bool p_flip_y = true, bool p_reverse_z = true, bool p_remap_z = true);
|
||||
|
||||
void set_light_atlas_rect(const Rect2 &p_rect);
|
||||
void set_perspective(real_t p_fovy_degrees, real_t p_aspect, real_t p_z_near, real_t p_z_far, bool p_flip_fov = false);
|
||||
|
||||
Reference in New Issue
Block a user