Projection Matrix 4x4 in layman's terms

Hello

I have a question to which I can’t find a description in layman’s terms. Lots of mathematics if I search the web but nothing it seems that explains what the maths does to each of the values and how that affects the view. For example if I play around with m[3,0] m[3,1] and m[3,2] I can see that it affects the way perspective is achieved. If set to zero, there is no perspective, lines run parallel and if a value is set, then a foreshortening effect is achieved in whichever direction chosen, thus you can get one point, two point and three point perspective depending on values set.
Likewise by playing around with the values of m[0,3], m[1,3] and m[3,3] I notice a a “panning” behaviour for the first two and a “zooming” behaviour for m[3,3], however I am not sure what is actually happening. I am guessing as I’m not moving the transform of the camera and this is all done with the projection Matrix then is the projection plane moving? Far plane? Near Plane? Relative to each other?
The row of m[2,0], m[2,1], m[2,2] and m[2,3] all seem to do with the clipping planes. Playing around with these values I can “eat” away objects in the scene, front and back, but also side to side and top to bottom. I am guessing that the side to side and top to bottom is to do with the actual visible area of the camera, or projected dimensions, so when objects fall outside the mapped area they are not rendered. The same for near and far clip planes, when objects are outside those they get “eaten” away.

Anyway these are just my guesses, so I would love for someone to explain what the values actually do. It would be useful for many I think. Thanks for your help community.

var m : Matrix4x4;
    m[0,0] = a;  m[0,1] = b;  m[0,2] = c;  m[0,3] = moveHorizontal;
    m[1,0] = e;  m[1,1] = f;  m[1,2] = g;  m[1,3] = moveVertical;
    m[2,0] = clipPlaneRotate?;  m[2,1] = clipPlaneRotate?;  m[2,2] = FarClip;  m[2,3] = NearClip;
    m[3,0] = perspectiveX;  m[3,1] = perspectiveY;  m[3,2] = perspectiveZ;  m[3,3] = moveDepth;
    return m;

Here’s a site that will you a better idea of what’s going on…

http://www.scratchapixel.com/lessons/3d-advanced-lessons/perspective-and-orthographic-projection-matrix/perspective-projection-matrix/

Hi JGB
Thank you for your reply,

That’s one of the sites I’ve been to and had a look. It does explain many things, but doesn’t quite (at least for me) get to naming what each bit of the matrix does. For example, which combination of m[?,?] controls the FOV. What I would like (wishful thinking perhaps) is a matrix written out with each variable telling me what it controls (in layman’s terms). For example…

m[0,0] = CentreOfInterest;  m[0,1] = FocalDistance;  m[0,2] = NearClipPlane;  m[0,3] = moveHorizontal;

    m[1,0] = FarClipPlane;  m[1,1] = EyeHorizontalOffset;  m[1,2] = EyeVerticalOffset;  m[1,3] = moveVertical;

etc… (fake code obviously):expressionless:

Cheers

That website has a very complete explanation. It’s all there, including the final result of the derivation…

1091968--40996--$perspectivematrix.png

Where:
f is the far clipping plane distance.
n is the near clipping plane distance.
fov is the field of view (degrees).

What you are asking is really a collection of questions. What is a matrix? How do the various components work? What is an affine transformation? What is a linear transformation? What is a 3D projection? Why are matrices non-commutative?

Wikipedia has a good collection of articles on the subject, though if you do not read mathematical notation you might be a bit lost. I suggest starting with “linear transformation” and “affine transformation” and “3D Projection.”

If you really want to get to understand these subjects and make it relevant to your day to day game programming I suggest “Mathematics for Game Developers,” “3D Math Primer for Graphics and Games” and “Mathematics for 3D Game Programming and Computer Graphics” which all include good coverage of the various concepts and how they are built up.

Thank you very much for the replies.

I will continue to study and report my findings here as I go along. I am an illustrator by trade and mathematics is not my strong point, however I I am willing to get my hands dirty and delve into the unknown. I just though that “demystifying” the Matrix (sounds like something out of a film by the Wachowski Bros) would be helpful to me and the community in general.

Last night I managed to get a very nice Isometric projection (see attached image) through manipulating the Projection Matrix. It’s not Pixel perfect, but good nonetheless as the x and y lines show a perfect 2:1 stair-stepping.

Just one more question… Does it matter how I set up the camera in the scene (editor values) or will the Matrix script I place on the camera override those settings? Seems to me like it does. Because no matter if my camera is “perspective” or “orthographic” the result when I click PLAY is the same. (I guess I just answered my own question) :wink:

Cheers

1092348--41013--$Screen Shot 2012-11-21 at 15.28.24.png