Skip to main content
GameDev.net gamedev.net
🔒 Locked

Clip space headache

Started by nexekho Sep 10, 2010 at 2:32 PM 4 replies 800+ views
Original Post
nexekho
nexekho
I need to know if a point is behind the eye. I have this point in clip space. I know the near and far clip planes. How can I calculate what the Z position of the eye is in clip space if my near plane is 1.0 and my far plane is 1024? It should be just beyond -1.0, I know that much, but not how to calculate the actual value.

Many thanks.
Zipster
Zipster
Clip space isn't the best place to be performing this kind of test, since things get wacky after the homogeneous divide -- view space would be better because all you have to check is Z < 0 (or Z > 0, depending on your coordinate system).
nexekho
nexekho
As in before the perspective is applied? I didn't think of that, I'll try it, thanks.
nexekho
nexekho
Just to wrap up, that works great, thanks. My frustum culling is now flawless. (needed to flip the X/Y coordinates of the bounding box coordinates behind the eye)
Zipster
Zipster
Quote:
Original post by Eric Lengyel
You might find slide 7 of the following presentation interesting:

http://www.terathon.com/gdc07_lengyel.pdf

Points behind the camera have positive values greater than (f+n)/(f-n) in clip space.

Ah yes, for some reason I forgot that the asymptotes were at Z=0 and Z'=(f+n)/(f-n) after the divide! Good reminder :) I guess that what happens when you step away from graphics for too long :/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.