OpenGL Near clipping problems

Recommended Posts

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?

Share on other sites
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.

Share on other sites
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.

Share on other sites
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.

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

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

Share on other sites
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.

Create an account

Register a new account

• Partner Spotlight

• Forum Statistics

• Total Topics
627682
• Total Posts
2978615
• Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 13
• 12
• 10
• 12
• 22