Making sense of the orthographic projection?

Can someone help understand the components of the orthographic projection? Unity’s projection matrix doesn’t seem to align with any standard documentation on how they’re put together. For example, a camera with a size of 2, near plane 0 and far plane 1000 generates this projection matrix

0.28125	0.00000	0.00000	0.00000
0.00000	0.50000	0.00000	0.00000
0.00000	0.00000	-0.00200	-1.00000
0.00000	0.00000	0.00000	1.00000

Just consider the first column – it’s supposed to be 2/(right-left) but instead it’s the aspect ratio of my display resolution divided by the projection size. The y-axis column is just 1/size.

Now, this does make some sense – the x-axis is scaled to respect the aspect ratio, the y-axis is left alone. And then scale down both the x and y axes to project a larger space based on ‘size’.

I get that the z-column is being scaled to fit in a range of 2, and then the z-component of the translation column is making that between -1 and 1. This is all based on the near/far plane.

I don’t understand is what’s going on the the x and y-components of the translation column. Why are they zero? Shouldn’t there be some sort of size/2 component to shift the space to the center of the camera?

Thanks ahead of time, I’m sure I’m just being dense.

1 Answer

1

You might find whatever information your missing here : Unity - Scripting API: Matrix4x4.Ortho
OpenGL Projection Matrix

The value of left, right and bottom, top might not be what you are expecting.

Ah, that's exactly what I was missing -- simplifying by choosing specific values for the nfrltb values. That's neat that the projection is implicitly centered from that construction. Thanks a bunch for pointing that out.