From 5f95999f32006b1197403263b33beb7987bfa973 Mon Sep 17 00:00:00 2001 From: junjie020 Date: Fri, 16 Jul 2021 11:22:43 +0800 Subject: [PATCH] fix frustumLH projection matrix get wrong result when left/right or top/bottom is not symmetries --- glm/ext/matrix_clip_space.inl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/glm/ext/matrix_clip_space.inl b/glm/ext/matrix_clip_space.inl index 7e4df330..2a7f6123 100644 --- a/glm/ext/matrix_clip_space.inl +++ b/glm/ext/matrix_clip_space.inl @@ -125,8 +125,8 @@ namespace glm mat<4, 4, T, defaultp> Result(0); Result[0][0] = (static_cast(2) * nearVal) / (right - left); Result[1][1] = (static_cast(2) * nearVal) / (top - bottom); - Result[2][0] = (right + left) / (right - left); - Result[2][1] = (top + bottom) / (top - bottom); + Result[2][0] = -(right + left) / (right - left); + Result[2][1] = -(top + bottom) / (top - bottom); Result[2][2] = farVal / (farVal - nearVal); Result[2][3] = static_cast(1); Result[3][2] = -(farVal * nearVal) / (farVal - nearVal); @@ -139,8 +139,8 @@ namespace glm mat<4, 4, T, defaultp> Result(0); Result[0][0] = (static_cast(2) * nearVal) / (right - left); Result[1][1] = (static_cast(2) * nearVal) / (top - bottom); - Result[2][0] = (right + left) / (right - left); - Result[2][1] = (top + bottom) / (top - bottom); + Result[2][0] = -(right + left) / (right - left); + Result[2][1] = -(top + bottom) / (top - bottom); Result[2][2] = (farVal + nearVal) / (farVal - nearVal); Result[2][3] = static_cast(1); Result[3][2] = - (static_cast(2) * farVal * nearVal) / (farVal - nearVal);