diff --git a/pytorch3d/renderer/cameras.py b/pytorch3d/renderer/cameras.py index d3d4ff24..3f411525 100644 --- a/pytorch3d/renderer/cameras.py +++ b/pytorch3d/renderer/cameras.py @@ -886,8 +886,8 @@ def compute_projection_matrix( # NOTE: This maps the z coordinate to the range [0, 1] and replaces the # the OpenGL z normalization to [-1, 1] - K[:, 2, 2] = z_sign * (1.0 / (zfar - znear)) * scale_xyz[:, 2] - K[:, 2, 3] = -znear / (zfar - znear) + K[:, 2, 2] = z_sign * (2.0 / (zfar - znear)) * scale_xyz[:, 2] + K[:, 2, 3] = -2*znear / (zfar - znear) return K @@ -910,12 +910,12 @@ def get_projection_transform(self, **kwargs) -> Transform3d: scale_z = 2 / (far-near) mid_x = (max_x + min_x) / (max_x - min_x) mix_y = (max_y + min_y) / (max_y - min_y) - mid_z = (far + near) / (far - near) + mid_z = 2 * near / (far - near) K = [ [scale_x, 0, 0, -mid_x], [0, scale_y, 0, -mix_y], - [0, 0, -scale_z, -mid_z], + [0, 0, scale_z, -mid_z], [0, 0, 0, 1], ] """