Dynamic near clip-plane error

Started by
2 comments, last by そら 4Β years, 5Β months ago

Hi everyone,

I'm computing the nearest/furthest point of a mesh (actually its bounding volume) to the camera and changing the near/far clip-plane dynamically accordingly, in order to keep depth buffer precision errors to its minimum.

However, after setting the closest point found as the near clipping plane I'm getting this error:

I've verified that there are no other points closer than the point being retrieved as the one nearest to the camera, but still that point being clipped. i.e. It can be the case that the closest point is in one of the corners of the box, but that corner is being clipped entirely.

Definitely adding a little offset to the near clip-plane would avoid the problem, but not sure that would be the proper solution; as. in theory, just passing the closest point should be working, but not sure why it's not.

Any ideas?

Thanks

PS.- Also, the offset needs to be of 0.12 for it to render properly, which is too much to be a precision problem.

"lots of shoulddas, coulddas, woulddas in the air, thinking about things they shouldda couldda wouldda donne, however all those shoulddas coulddas woulddas ran away when they saw the little did to come"
Advertisement

It seems to clip properly against the plane that is parallel to the front face, so I think you're not correctly updating the closest point. Note that you need the distance to the plane the point lies on, and not the distance to the point itself. Hope this helps.

Prototype said:

Note that you need the distance to the plane the point lies on, and not the distance to the point itself. Hope this helps.

Aaahhh!… yeah, ofcourse, you're right…

the distance from the camera to the point itself will always be a little bit larger when not looking straight to the point, hence after adjusting the near-clipping plane the geometry close to the edges ends up closer to the plane than to the camera, and it clips it.

Thanks!.. changed it to compute the distance to the plane and everything's working as it should now.

"lots of shoulddas, coulddas, woulddas in the air, thinking about things they shouldda couldda wouldda donne, however all those shoulddas coulddas woulddas ran away when they saw the little did to come"

This topic is closed to new replies.

Advertisement