/// <summary> /// Creates a matrix for a symmetric perspective-view frustum with far plane /// at infinite for graphics hardware that doesn't support depth clamping. /// </summary> /// <param name="fovy">The fovy.</param> /// <param name="aspect">The aspect.</param> /// <param name="zNear">The z near.</param> /// <returns></returns> public static Matrix4f tweakedInfinitePerspective(float fovy, float aspect, float zNear) { float range = Trigonometric.Tan(fovy / (2)) * zNear; float left = -range * aspect; float right = range * aspect; float bottom = -range; float top = range; Matrix4f Result = new Matrix4f((0f)); Result[0, 0] = ((2) * zNear) / (right - left); Result[1, 1] = ((2) * zNear) / (top - bottom); Result[2, 2] = (0.0001f) - (1f); Result[2, 3] = (-1); Result[3, 2] = -((0.0001f) - (2)) * zNear; return(Result); }
/// <summary> /// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite. /// </summary> /// <param name="fovy">The fovy.</param> /// <param name="aspect">The aspect.</param> /// <param name="zNear">The z near.</param> /// <returns></returns> public static Matrix4f infinitePerspective(float fovy, float aspect, float zNear) { float range = Trigonometric.Tan(fovy / (2f)) * zNear; float left = -range * aspect; float right = range * aspect; float bottom = -range; float top = range; var result = new Matrix4f(0); result[0, 0] = ((2f) * zNear) / (right - left); result[1, 1] = ((2f) * zNear) / (top - bottom); result[2, 2] = -(1f); result[2, 3] = -(1f); result[3, 2] = -(2f) * zNear; return(result); }