My scene is organized with a simple scene graph where the child multiplies its transformation with the one of the parent.

For normal objects, likes meshes, this works as expected, but I also want to insert the camera into the scene graph. To get the view-matrix I need to take the inverse of the global transformation matrix, which works except that this messes up the near/far plane dimensions. Because if a node above the camera has a scaling of 0.1 (across every dimension) the inverse will scale the whole world by a factor of 10.

Is there a simple way to get rid of the scaling or do I need to update my near and far plane based on the final view scaling?

  • \$\begingroup\$ Putting the camera inside a scaled parent sounds dangerous to me. We can hack around it, but it seems simpler & safer to not do it in the first place. Is this scaled nesting of the camera a hard requirement for your game? \$\endgroup\$
    – DMGregory
    Commented Sep 20, 2018 at 14:08
  • \$\begingroup\$ @DMGregory I do not have to add it to a scaled parent, but I wanted to handle the case where I do it on accident. I also wonder how unity/unreal handle such a case. \$\endgroup\$ Commented Sep 20, 2018 at 14:13

1 Answer 1


You can remove a uniform scale from an affine transformation matrix (including a View matrix) by taking the three columns (or three roes) of the top-left 3x3 block of the matrix and normalizing each one, as though they were ordinary 3-vectors.

Do this before multiplying by your projection matrix, since after this your matrix represents a perspective transformation, not an affine transformation anymore.

Note that if you have a non-uniform scale somewhere in your hierarchy, you can get into a more complicated situation where the axes are no longer perpendicular to one another. You can orthonormalize the upper-left 3x3 block to correct this, but the results will depend on how you choose to compromise between the three axes' directions, so it's tough to define an unambiguous "correct" output for this case. I recommend using non-unform scales only at the leaf nodes of your scene graph, and avoiding it in parent nodes wherever possible.

  • \$\begingroup\$ Thanks for the extensive answer. Probably gonna handle the uniform scaling case, and add an error log if non uniform scaling is detected in the view-matrix. \$\endgroup\$ Commented Sep 20, 2018 at 14:52

You must log in to answer this question.

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