Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Near and Far clipping ratios

  1. #1
    Senior Member Regular Contributor
    Join Date
    Oct 2000
    Location
    USA
    Posts
    302

    Near and Far clipping ratios

    I know it is advisable to keep the near and far clipping planes' ratio low. But what is the recommended ratio? I've heard the near plane should be 1.0 but this leads to an inability to get very close to objects, but then you could overcome this apparant inability to get close to objects by drawing them much larger, however, then you have the problem that you're more limited to the distance of objects. For example, I'm drawing a planet, and I want to be able to fly VERY close to the surface of the planet. But to achieve this appearance with the near plane set to 1.0, I have to make the planet *HUGE* (in terms of its radius)! Otherwise, I hardly get close to the planet at all and BAM I'm inside the planet. I realize the ratio can be larger with a larger Z-buffer (32bit). But is current hardware well equiped to use a 32bit Z-buffer? Or is it best to stick with 16bit? And, taking all of this into consideration, what is the best way to simulate things like space and drawing HUGE objects like planets and EXREMELY distant objects like stars? Are there any tricks anyone has they'd like to share?

    I remember a long time ago (in a galaxy far, far away) there was a title called Microsoft Space Simulator. It was monster cool because you could pump the time compression way up and fly at near-light speeds through the galaxy. You could start somewhere within the solar system and you'd see the actual stars in their real places. And then you could accelerate and you'd see the planets of the solar system whiz past and become little dots in the distance and eventually, you'd begin to see the stars that make up familiar constelations start to move and then you could eventually fly around them and see how they didn't lay on a flat plane as they appear from our solar system. This kind of _LARGE_SCALE_ universe is what I'm seeking to create and I'm just wondering if anyone has any tricks to rendering _DISTANT_ objects and still maintain accurate depthbuffering.

  2. #2
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Nov 2010
    Posts
    2,466

    Re: Near and Far clipping ratios

    2 options
    measure the zvalues of everything in your scene everyframe and set the near/far values to those every frame.
    or use 2 depth ranges ie draw all the near stuff change the near/far planes and draw all the far stuff.
    ive done it this way with a space thing and IIRC there was no zfighting from 1m to a billion kilometers

  3. #3
    Senior Member Regular Contributor
    Join Date
    Oct 2000
    Location
    USA
    Posts
    302

    Re: Near and Far clipping ratios

    So you did it using the second method you mentioned? Cool! Thanks, man! Could you elaborate a bit on how you actually implemented that system? How do you actually use two different depth systems and how do you handle the rendering of something like that? I've heard if you use a near clipping of less than 1.0 you'll run into problems. But are you saying this is not the case? Thanks again!

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Dec 2007
    Posts
    1,077

    Re: Near and Far clipping ratios

    I can't understand how you're generalizing the zbuffer problem.
    It's always cool to have the distance between the planes as small as possible, but the scale of the displayed object should specify the ideal ration (would be limes to zero... ). So, get the maximum z value of any object (you can use bounding spheres) and the minimum z value, and use them. It should always give the best results.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Dec 2007
    Posts
    1,077

    Re: Near and Far clipping ratios

    Whoops, I think I oversaw some details in your question. Sorry.
    Maybe, you don't really let the far-away object get far away, but do a lod with scaling the object down appropriately.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Oct 2000
    Location
    USA
    Posts
    302

    Re: Near and Far clipping ratios

    Originally posted by Michael Steinberg:
    Whoops, I think I oversaw some details in your question. Sorry.
    Maybe, you don't really let the far-away object get far away, but do a lod with scaling the object down appropriately.
    That sort of technique might work for some things, but for other things, you'd lose the whole feature of depth buffering: occlusion. Do you have any ideas as to how to implement this other guy's suggestion? It sounds pretty good especially seing as how he says he's already implemented it with success. Although, depth-sorting everything before rendering is something I havn't had to deal with yet.

  7. #7
    Member Newbie
    Join Date
    Oct 2000
    Posts
    32

    Re: Near and Far clipping ratios

    Punchey,

    You don't have to depth sort everything, its more of a case of picking a distance and having objects as being either in front of or behind that imaginary 'line'.

    In its simplest form, you just test each object as you go to draw it and put objects on the near side of the imaginary line aside for the next pass with the 'closer' far and near clipping planes.

    When you do the second pass, just clear the Z-Buffer (but not the frame buffer obviously) before you draw.

    I guess that if your distance is very large, you could use several of these 'clipping bands'

    I haven't actually done it yet, but plan to soon. I'm sure there are a few things I haven't covered like what to do with objects that straddle the boundry and such,and I'm sure there are more efficient implementations than my simple explaination.

  8. #8
    Senior Member Regular Contributor
    Join Date
    Oct 2000
    Location
    USA
    Posts
    302

    Re: Near and Far clipping ratios

    well, you'd have to do more than just clear the Z-buffer. You'd have to reset the near and far clipping planes because you'd still get depth fighting. The problem I'm running into is if I draw using a near clip of 1.0, it looks as though I can never get close to anything like a planet or such. If I make the planet large enough to look good so that I can get what looks to be reasonably close to it without it dissapearing, then when I fly away from the planet, it dissapears beyond the far clipping plane FAR too early. So I'm at a loss of what to do. Is it much of a performance penalty to reset your near and far clipping planes each frame? And if not, which calls are best to use to accomplish this? Also, I'm noticing that whether I use a 16bit or 32bit Z-buffer, it still has the same ammount of depth fighting.

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Dec 2007
    Posts
    1,077

    Re: Near and Far clipping ratios

    I think it's almost necessary to reset the clipping planes every frame, just to improve visuals. For my own purposes it seems to be far easier though than to yours...
    Maybe replace the galaxies with a simple billboard when you are far enough away. They won't get depth fighting then. You could even project them on a sphere or something else. It's just that you can't see a whole galaxy detailed from one point. AND maybe it is more easily to apply your own depth sorting, only drawing them over each other. I mean, planet's don't intersect, so you can sort them and do a far to near rendering without depth test. That would be the way, I think.
    And planets are almost always convex.

    [This message has been edited by Michael Steinberg (edited 12-05-2000).]

  10. #10
    Senior Member Regular Contributor
    Join Date
    Oct 2000
    Location
    USA
    Posts
    302

    Re: Near and Far clipping ratios

    About the 32-bit Z-buffer thing, do you know if there's a big performance premium on today's hardware for using one as opposed to a 16-bit Z-buffer? I'm beginning to think I'm going to need a whole message board dedicated to the topic of Space combat sims. The reason being that after getting into it and trying to implement things like laser beams and stuff I just have a TON of questions to ask. If anyone else out there is doing something like this themselves, it wouldn't hurt for us to collaborate together and brainstorm to come up with some solutions to these very basic problems.

Page 1 of 3 123 LastLast

Similar Threads

  1. managing multiple aspect ratios
    By blubee in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-11-2015, 08:35 AM
  2. Perspective projection stretches at -certain- aspect ratios?
    By Nick Wiggill in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-07-2012, 08:59 PM
  3. Replies: 1
    Last Post: 09-02-2003, 01:45 PM
  4. Clipping (not clipping) in opengl
    By FunkyLovin in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 06-04-2001, 05:08 AM
  5. FPS, Clipping, ....
    By Neals Shnyder in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 03-26-2001, 09:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean