Is there any reason besides pure perversity that metal uses a left hand coordinate system?
Accepted Reply
I'm discovering…
If I understand well, that comes from some openGL origin of Metal.
https://stackoverflow.com/questions/4124041/is-opengl-coordinate-system-left-handed-or-right-handed
So "perversity" is OpenGL, but the link explains the rationale behind .
-
From your link I gather that OpenGL uses left hand coordinates but they end up as right hand coordinates by the projection matrix transform. All I know is that in porting a project from OpenGL, in which I designed my geometry with right hand coordinates, to Metal I found that everything came out **** backward. Would you know how to set up a Metal projection matrix so that it works the same as in OpenGL?
Replies
I'm discovering…
If I understand well, that comes from some openGL origin of Metal.
https://stackoverflow.com/questions/4124041/is-opengl-coordinate-system-left-handed-or-right-handed
So "perversity" is OpenGL, but the link explains the rationale behind .
-
From your link I gather that OpenGL uses left hand coordinates but they end up as right hand coordinates by the projection matrix transform. All I know is that in porting a project from OpenGL, in which I designed my geometry with right hand coordinates, to Metal I found that everything came out **** backward. Would you know how to set up a Metal projection matrix so that it works the same as in OpenGL?
Included in the sample code project MigratingOpenGLCodeToMetal is the file AAPLMathUtilities. This file contains two functions for creating projection matrixes:
/// Constructs a symmetric perspective Projection Matrix
/// from left-handed Eye Coordinates to left-handed Clip Coordinates,
/// with a vertical viewing angle of fovyRadians, the specified aspect ratio,
/// and the provided absolute near and far Z distances from the eye.
matrix_float4x4 AAPL_SIMD_OVERLOAD matrix_perspective_left_hand(float fovyRadians, float aspect, float nearZ, float farZ);
/// Constructs a symmetric perspective Projection Matrix
/// from right-handed Eye Coordinates to left-handed Clip Coordinates,
/// with a vertical viewing angle of fovyRadians, the specified aspect ratio,
/// and the provided absolute near and far Z distances from the eye.
matrix_float4x4 AAPL_SIMD_OVERLOAD matrix_perspective_right_hand(float fovyRadians, float aspect, float nearZ, float farZ);
So, I guess one can define the geometry of one's objects using either a right hand or a left hand coordinate system and have it display properly depending on which of these two one uses to construct the projection matrix.
This is good. I think I understand things much better now.