Sign in to follow this  
DrGUI

Projection left, right, top, bottom, znear, zfar

Recommended Posts

DrGUI    402
Hi guys I wish to split a projection matrix into sections, so I can render high-res screenshots of my game. I try to do this by retrieving the left, right, top, bottom, znear, zfar parameters from the projection matrix, partitioning into however many sections by interpolating between them, then recreating the projection matrices using these interpolated parameters. My function ExtractPoints returns the 8 corners of the view frustum from an arbitrary matrix, and my ExtractParameters function returns the left, right, bottom, top, znear and zfar parameters from an arbitrary matrix. These work fine when used on a view.projection concatenation, but do not give the desired results when used on just a projection matrix. To ensure that it wasn't my splitting code at fault, I tried it as in the pseduo code below: projection = CreateMatrix(left, right, bottom, top, zNear, zFar) left2, right2, bottom2, top2, zNear2, zFar2 = ExtractParameters(projection) projection2 = CreateMatrix(left2, right2, bottom2, top2, zNear2, zFar2) projection and projection2 are different matrices, as left, left2, right, right2 etc are different values. I hope that's clear...

Share this post


Link to post
Share on other sites
LilBudyWizer    491
Well, you need to know how the matrix is actually built. Once you have that build it by hand and check it against what you're getting. You might find, for example, that the actual matrix is the transpose of what you thought it would be. Once you're sure the matrix is laid out as you thought build it symbolically and extract the components, i.e. use l, r, t, b, n, f rather than actual numbers. You may find the extraction is wrong but that simple manipulation of what you have will give you want you want, i.e. l-r and r-l rather than r and l.

Share this post


Link to post
Share on other sites
JohnBolton    1372
Looks like your CreateMatrix and ExtractParameters functions may be broken. Both the D3D and OpenGL docs describe how the projection matrix is built. Compare that to your CreateMatrix function. Once you have verified that your CreateMatrix function works correctly, you can use test cases to figure out what is wrong with the ExtractParameters function.

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