Sign in to follow this  
Hinch

scarey projection matrix!

Recommended Posts

Hi all, Given a projection matrix (I'm using directX) I need to be able to grab the parameters used to create this matrix, in terms of: Near plane, Far plane, top, bottom, right, left. Where top, bottom, right and left are distances along the x and y axes in camera space. I already know the near and far values which should make it somewhat easier. Now I understand the projection matrix converts from camera space to normalised coordinates, which in DirectX range from -1.0 to 1.0 in the x and y axes, and from 0.0 to 1.0 along the z, with the viewer facing along positive z. So my idea was to invert the projection matrix, and feed the following vectors through: (1.0, 1.0, 0.0, 1.0), and (-1.0, -1.0, 0.0, 1.0) The idea being that these will come out with the right & top values in camera space in the first vector, and bottom and left values in the second vector. This 'sort-of' works, but the FOV seems slightly wider than with the original matrix - if I take a screen capture with the original camera, then make a new camera from parameters extracted from the original and take another screen capture, the two don't quite match up. There must be something I've missed here! Anyone have any idea as to what? Ta :) [Edited by - Hinch on February 9, 2005 11:50:11 AM]

Share this post


Link to post
Share on other sites
Make sure you're not confusing vertical with horizontal FOV and take aspect ratio into account. Depending on how you calculate FOV you might also have forgotten to halve or double it before re-configuring your camera with the extracted parameters.

Share this post


Link to post
Share on other sites
Hmm nice thinking, but I've already tried both of those. :) The FOV difference is a lot more subtle than would be caused by either of those bugs anyway - it's only very slightly off. At first glance, the new image appears identical but after looking at certain details it's possible to see differences - it's actually quite fun trying to spot them. (I know, very sad) :P

I'm beginning to think it might be caused by build-up of floating point error since it's such a small difference, and also because it seems to vary between Release and Debug builds where there are different floating-point roundoff errors.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this