Projection matrix

Started by
3 comments, last by brekehan 14 years, 11 months ago
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.
Advertisement
You can't have the near clipping plane be zero. If you look at the math involved, this results in division by zero.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
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...


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.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
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 ...

This topic is closed to new replies.

Advertisement