Near clipping problems

Started by
5 comments, last by hplus0603 17 years, 8 months ago
I've made a terrain renderer, however I got some nearclipping problems when you're really close to the surface of the terrain. I've tried playing with the near value of gluPerspective but never got any good results. Right now I have 1 opengl unit as 1 meter(approx. 3 feet), should I instead use 1 unit as 1 decimeter(0.1meters) instead?
Advertisement
OpenGL doesn't care at all about absolute measures, so changing unit to real world mappings won't make any difference what so ever.

The problem you have is, as I understand it, that basically you can see through the ground where the surface intersects the near clip plane. Not really much you can do easily except for restricting how close to the ground the viewpoint can be. Maybe you shouldn't allow the user to go as close as (s)he may want to, but stop just before the problem occurs.
Are you sure OpenGL doesn't care at all about absolute measures?
If the landscape is larger in comparison to the camera then you should be able to get closer before you begin to clip through it..or is my logic gone wrong?

~ since when you scale, you scale everything including the height of the player.
Maybe it's too restricted, but i sometimes use the extension

GL_NV_depth_clamp

to avoid near and far clipping. give it a try if you have the oportunity.
_____My little engine : I.E.
Quote:Original post by Brother Bob
OpenGL doesn't care at all about absolute measures, so changing unit to real world mappings won't make any difference what so ever.

The problem you have is, as I understand it, that basically you can see through the ground where the surface intersects the near clip plane. Not really much you can do easily except for restricting how close to the ground the viewpoint can be. Maybe you shouldn't allow the user to go as close as (s)he may want to, but stop just before the problem occurs.


Well I think it does I mean, for example, right now I got my camera 1.7 units above ground, however if I would increase the scale on the terrain by 10 times, the camera would be 17 units above ground, and then I should be able to have the near clipping plane at 1.0 and even further away without ever seeing any clipping. I'm pretty sure of this, however I'm not sure if this is the right way to go.
Quote:Original post by stevenmarky
Are you sure OpenGL doesn't care at all about absolute measures?
If the landscape is larger in comparison to the camera then you should be able to get closer before you begin to clip through it..or is my logic gone wrong?

~ since when you scale, you scale everything including the height of the player.

Since you scale everything, you also scale the near and far clip plane distances. You can't get closer unit-wise, because the clip plane will clip further away by the same amount you scaled the scene.

Quote:Original post by angry
Quote:Original post by Brother Bob
OpenGL doesn't care at all about absolute measures, so changing unit to real world mappings won't make any difference what so ever.

The problem you have is, as I understand it, that basically you can see through the ground where the surface intersects the near clip plane. Not really much you can do easily except for restricting how close to the ground the viewpoint can be. Maybe you shouldn't allow the user to go as close as (s)he may want to, but stop just before the problem occurs.


Well I think it does I mean, for example, right now I got my camera 1.7 units above ground, however if I would increase the scale on the terrain by 10 times, the camera would be 17 units above ground, and then I should be able to have the near clipping plane at 1.0 and even further away without ever seeing any clipping. I'm pretty sure of this, however I'm not sure if this is the right way to go.

If scaling the scene 10 times and having the near clip plane at 1.0 solves your problem, then so does not scaling the scene and having the clip plane at 0.1. Try it. There's no difference at all. All OpenGL cares about are the relative proportions between things.
In general, though, it's good to have your clip plane at least 0.5 meters out from the camera, in physical space (more is better). This is to avoid ugly Z fighting artifacts.

Typically, what you'll want to do with a camera is to create a collission ball around the camera, that is slightly larger than the clip distance. That way, you know that the camera will never come close enough to geometry to clip it. Then make the ball (and distance) as large as gameplay and level design will let you.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement