summaryrefslogtreecommitdiffstats
path: root/core/math/camera_matrix.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2021-01-20 00:10:21 +0100
committerGitHub <noreply@github.com>2021-01-20 00:10:21 +0100
commit8a6d4dd5ed770f4dc464bbc6af912b96c63bbc2c (patch)
tree357c7089c986be1f7d9a97e275424ffc326c6a8d /core/math/camera_matrix.cpp
parentf768d8651687cd80da85043c4446b9e0a50f39ef (diff)
parent099dee35f47db3e293cb8e60287ffe6a44f3d5d4 (diff)
downloadredot-engine-8a6d4dd5ed770f4dc464bbc6af912b96c63bbc2c.tar.gz
Merge pull request #45023 from reduz/optimize-shader-vgpr1
Shader optimizations to reduce VGPR usage and increase occupancy
Diffstat (limited to 'core/math/camera_matrix.cpp')
-rw-r--r--core/math/camera_matrix.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index 9ec71af57f..7dbda1d149 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -74,6 +74,15 @@ Plane CameraMatrix::xform4(const Plane &p_vec4) const {
return ret;
}
+void CameraMatrix::adjust_perspective_znear(real_t p_new_znear) {
+ real_t zfar = get_z_far();
+ real_t znear = p_new_znear;
+
+ real_t deltaZ = zfar - znear;
+ matrix[2][2] = -(zfar + znear) / deltaZ;
+ matrix[3][2] = -2 * znear * zfar / deltaZ;
+}
+
void CameraMatrix::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) {
if (p_flip_fov) {
p_fovy_degrees = get_fovy(p_fovy_degrees, 1.0 / p_aspect);