# Projection matrix

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

## 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 on other sites
You can't have the near clipping plane be zero. If you look at the math involved, this results in division by zero.

##### Share on other sites
Quote:
 Original post by smart_idiotYou 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 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 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 ...

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633768
• Total Posts
3013743
×