- Home /

# Is this a valid projection matrix and why?

Hi,

from several AR/VR headset I keep getting projection matrices, having non zero value in the second column/ first row.

I wasn't able to find an explanation for this. Is it possible that this is related to some lens correction effect?

Thanks

Edit: This is some example projection matrix data (Samsung Odysee Plus MRTK v2):

```
0.8804515
```**-0.00124849** -0.08054376 0
0 0.7055852 0.0006020069 0
0 0 -1.0002 -0.20002
0 0 -1 0

are you sure it's the projection matrix and not a world/view matrix ?

**Answer** by Bunny83
·
May 21 at 05:17 PM

Well, first of all I recommend to read through my Matrix crash course (If you have trouble reading due to UnityAnswers broken Markdown rendering, I have a clone on github).

Next thing to realise is that matrices can only do affine transformations. Thanks to homogeneous coordinates we can actually do a perspective projection as well as translation with a matrix. Any other non linear operation is not possible using a matrix since matrix multiplication only uses multiplication and addition. So lens distortion can not be fixed with a matrix. Only linear factors can be used (offsets, rotations or shear operation. Even trapezoid transformations are not possible since they are not affine)

To describe what the "3 unusual" values do I start with the 2 values in the 3rd column. Like i explained in my crash course they essentially shift the center of perspective left / right and up / down. However if you look closely on the values you will realise they are quite small. So they are just calibration values for the camera. You have a shift of about 9% on the vertical axis and about 0.09% on the horizontal axis.

The other unusual value (second column, first row) is really unusual for a projection matrix. It will cause a shear operation. However again if you look at the value (0.0012) it's very close to 0. It would cause a slight shear angle of about 0.08 degree. So the vertical lines are tilted by about 0.08°. At a vertical resolution of 1080p that would be about 1.5 pixels off. (So a vertical line from top to bottom would end 1.5 pixels to the left / right from the starting point). Using 0 for this value wouldn't cause almost no change at all.

ps:

I did already write a similar answer 4 days ago but I wasn't home and only had access to a "rudimentary PC". When I submitted the answer, UA decided to give my a 504 Gateway timeout and it was gone for good. So this is a complete rewrite ^^.

Thanks for the link! I already know about matrix math and how to construct a projection matrix. But that is why I wonder where the second column, first rows value is coming from. Though the shear is negligible, someone has an idea why some of the mixed reality headsets are setting it.

Well who knows. It could be a fragment of a more complex calculation / calibration routine. The same way when you calculate the inverse of a certain matrix and multiply the original with its own inverse the result is essentially the identity matrix with some close to zero values off the main diagonal.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

How to project a 3D object onto the screen 0 Answers

Render texture fullscreen on top of camera output 0 Answers

Matrix Multiplication, Standard Deviant and More usefull methods 2 Answers

Set shader builtin matrices by script 0 Answers

Errors calculating clip-space Z position on the CPU side 0 Answers