1
votes

This is how the result looks like: enter image description here

and the same result using an Orthogonal matrix: enter image description here

Any idea why using the projection matrix makes everything look weird?

My Perspective:

 inline static Matrix<T> ProjectionPerspectiveOffCenterLH(const T left, const T right, const T bottom, const T top, const T zNear, const T zFar)
  {
    return Matrix<T>(
      (2.0f * zNear) / (right-left), 0.0f, 0.0f, 0.0f,
      0.0f, (2.0f * zNear) / (top-bottom), 0.0f, 0.0f,
      (left+right)/(left-right), (top+bottom)/(bottom-top), zFar / (zFar - zNear), 1.0f,
      0.0f, 0.0f, (zNear * zFar) / (zNear - zFar), 0.0f);
  }

My Orthogonal:

inline static Matrix<T> ProjectionOrthogonalOffCenterLH(const T left, const T right, const T bottom, const T top, const T zNear, const T zFar)
  {
    T farNear = zFar - zNear;

    return Matrix<T>(
      2.0f / (right-left), 0.0f, 0.0f, 0.0f,
      0.0f, 2.0f / (top-bottom), 0.0f, 0.0f,
      0.0f, 0.0f, 1.0f / farNear, 0.0f,
      (left + right) / (left - right), (top + bottom) / (bottom - top), -zNear / farNear, 1.0f);
  }
1
You should do some basic debugging. Run some test coordinates through your code.Oliver Charlesworth
@Oliver I tested it using a Vector3 and compared perspective and orthogonal. Only the Z axis was different (perspective's Z was 1 greater than orthogonal). So theres something wrong with the Z axis?PuRe

1 Answers

0
votes

Just found out why this happens:

In my Perspective Matrix the FOV is 0°. That's why it looks like that. So better use a Perspective FOV Matrix.