I am trying to draw simple model, but I am experiencing strange error. When I use this View matrix:

Matrix.CreateLookAt(new Vector3(0, 200, 1), new Vector3(0, 0, 0), Vector3.Up);

my model is drawn correctly. But when I set camera position Z to 0 like this:

Matrix.CreateLookAt(new Vector3(0, 200, 0), new Vector3(0, 0, 0), Vector3.Up);

nothing is rendered. Why?


1 Answer 1


This is probably because your up vector is exactly opposite to the eye vector in the second example. This makes the cross product, which is used to calculate the view matrix unreliable (for a lack of a better word).

EDIT: If this is not enough information, then you should read up on how a view matrix is calculated. You need three things to do that, an eye vector, an up vector and the camera position. Then the cross product is used to calculate a 4x4 matrix which transforms your points from world space into camera space. In the CreateLookAt function, the eye vector is calculated simply by subtracting the target position from the camera position, then normalizing the result.

So in your second example, the calculated eye vector is pointing straight down, while the up vector is pointing straight up. This means that you can't calculate the cross product between the eye vector and the up vector, which means that the view matrix can't be constructed. I say "can't", it can, but you get errors.

  • \$\begingroup\$ In the second case the result is undefined, as there is an unlimited amount of solutions or more exactly there is no solution where the requested up vector is pointing up in the resulting matrix. Basically the same problem as in (gamedev.stackexchange.com/questions/45280/…) any many other questsions on se. \$\endgroup\$
    – Archy
    Commented Dec 10, 2012 at 13:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .