• Advertisement
Sign in to follow this  

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

This topic is 4469 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
Sign in to follow this  

  • Advertisement