Jump to content
  • Advertisement
Sign in to follow this  
brekehan

Projection matrix

This topic is 3319 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

When I set a projection matrix with a 0.0 near and a 1.0 far: D3DXMatrixOrthoLH(&newProjection, static_cast<float>(viewport.Width), static_cast<float>(viewport.Height), 0.0f, 1.0f); My image seems to get clipped if it is set to a position of 1.0 z, via my world matrix. However, it does not get clipped if it is set to a position of 0.0 z, via my world matrix. Is that how it is suppose to work? Small detail, but I was saying 0 to 1 inclusive in my documentation, which doesn't match the behavior. It seems I have a range of 0 to 0.9999999999 (however many digits in a float) Or perhaps I have a code error? The vertices in my vertex buffer are created with a 0.0 z. EDIT: I suppose this might be true for all matrices? I haven't tried it for other types yet. Stuck in my image code right now. I do believe I set up my 3D matrix using a 0 near and 1000 far and has the same. Clipping at the z equal to far, but no clipping at 0.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by smart_idiot
You can't have the near clipping plane be zero. If you look at the math involved, this results in division by zero.


Ok, it looks like my 3D projection matrix does have a near clip of 0.1f
However, the 2D projection matrix, indeed has a near clip of 0.0f, and it runs without any errors...


Share this post


Link to post
Share on other sites
Sorry, what I said shouldn't apply to an orthographic projection.

The question comes down to, should something exactly on the clipping plane be clipped, or must it be beyond it?

In fact, it's moot, because you can't trust floating point numbers to come out exactly right anyway. You should always expect slight rounding errors, so if you want things at exactly 1.0 to remain visible, you should move it back slightly, just to be safe.

Share this post


Link to post
Share on other sites
OK, that makes sense.
0 doesn't have much room for error, but maybe 1.0 does after all the matrix math...
I don't think the 1.0 gets directly stored, it was something like q/n-f ...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!