diff --git a/impeller/geometry/geometry_unittests.cc b/impeller/geometry/geometry_unittests.cc index c2b10a32d6798..8ba3c6e9b719d 100644 --- a/impeller/geometry/geometry_unittests.cc +++ b/impeller/geometry/geometry_unittests.cc @@ -284,8 +284,8 @@ TEST(GeometryTest, MatrixMakePerspective) { auto expect = Matrix{ 3.4641, 0, 0, 0, // 0, 1.73205, 0, 0, // - 0, 0, -1.22222, -1, // - 0, 0, -2.22222, 0, // + 0, 0, -1.11111, -1, // + 0, 0, -1.11111, 0, // }; ASSERT_MATRIX_NEAR(m, expect); } @@ -295,8 +295,8 @@ TEST(GeometryTest, MatrixMakePerspective) { auto expect = Matrix{ 0.915244, 0, 0, 0, // 0, 1.83049, 0, 0, // - 0, 0, -3, -1, // - 0, 0, -40, 0, // + 0, 0, -2, -1, // + 0, 0, -20, 0, // }; ASSERT_MATRIX_NEAR(m, expect); } diff --git a/impeller/geometry/matrix.h b/impeller/geometry/matrix.h index 2a622a4ed2f63..a3c300dda1830 100644 --- a/impeller/geometry/matrix.h +++ b/impeller/geometry/matrix.h @@ -336,14 +336,13 @@ struct Matrix { Scalar z_far) { Scalar height = std::tan(fov_y.radians * 0.5); Scalar width = height * aspect_ratio; - Scalar z_diff = z_near - z_far; // clang-format off return { - 1.0f / width, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f / height, 0.0f, 0.0f, - 0.0f, 0.0f, (z_near + z_far) / z_diff, -1.0f, - 0.0f, 0.0f, (2.0f * z_near * z_far) / z_diff, 0.0f + 1.0f / width, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f / height, 0.0f, 0.0f, + 0.0f, 0.0f, z_far / (z_near - z_far), -1.0f, + 0.0f, 0.0f, -(z_far * z_near) / (z_far - z_near), 0.0f, }; // clang-format on }