0
votes

I'm researching related to custom distorted projection. To experiment with unity, I have to convert OpenGL projection matrices into Unity projection matrix.

I wonder Unity is using left-handed coordinate but OpenGL is using right-handed coordinate. And vertices are represented as a row vector, not a column vector.

How should I convert the matrix?

1
According to this Unity forum post, Unity matrices are column-major (like in OpenGL), vectors are column vectors, and a right-handed coordinate system is used. The matrix should therefore be identical.Nico Schertler

1 Answers

1
votes

To switch from column to row vector semantics transpose the matrix. To transform from right handed to left handed (or vice versa) mirror one of the axes (it doesn't really matter, which one, but the usual choice is Z). Last but not least you probably must swizzle the axes by having 1 or -1 at the right places in the matrix. For example to mirror Z and permute X→Y, Y→Z, Z→X you can use

0  0 -1
1  0  0
0  1  0