Decent distances for near and far clip planes for large scale world

Discussion in 'Game Development (Technical)' started by zoombapup, Dec 2, 2011.

  1. zoombapup

    Moderator Original Member

    Joined:
    Nov 25, 2004
    Messages:
    2,890
    Likes Received:
    0
    Hey all.

    I'm working on a game which is meant to have a large world space. But I'm worried about the overall scale of the space and the near and far clip settings.

    Anyone know what the usable minimum/maximum/recommended min/max are for those values to maintain a reasonable depth quality in a zbuffer etc?

    My world is divided into cells, so its only really an intra-cell value I want to ensure I generate content within the bounds of. But not sure what are suitable values for the max and appropriate min.

    This is using GLSL/GL.
     
  2. Vino

    Vino New Member

    Joined:
    May 16, 2010
    Messages:
    345
    Likes Received:
    0
    The smaller your min and larger your max, the less resolution your depth buffer will have, so you're more likely to run into problems with z fighting on objects far away. The most common solution is to render multiple scales, like a skybox. Other than that there's no real limitation other than don't put your min at <= 0
     
  3. jcottier

    jcottier New Member

    Joined:
    Jul 12, 2006
    Messages:
    1,386
    Likes Received:
    0
    Your problem is NearClipping. Move it as far away as you can.Even better, if you could do it dynamically, you'll get optimal result (for example if you zoom out to the sky watching your town, you could really gain by massively increasing nearclipping).

    JC
     
  4. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    Unless your scene is pretty damned boring, I think this is a moot problem tbh. I've never once run into an issue of z-buffer resolution before I hit an issue with frame rate.
     
  5. jcottier

    jcottier New Member

    Joined:
    Jul 12, 2006
    Messages:
    1,386
    Likes Received:
    0
    > Unless your scene is pretty damned boring, I think this is a moot problem tbh.

    It is definitely a problem you'll see with open ended worlds with tiny obj sitting on top of massive one. If you can zoom in an see a worm in an apple or zoom out see people like ants, you'll definitely need to manage your near clipping with caution :)

    JC
     
  6. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    Well, yes. Lemme know when there is a game like that :)
     
  7. jcottier

    jcottier New Member

    Joined:
    Jul 12, 2006
    Messages:
    1,386
    Likes Received:
    0
    This one for example :)

    "Black & White employs an auto-scaling graphics engine which allows the view to pull back to a point several miles above sea level and smoothly zoom in far enough to see a single worm wriggling into an apple at the village store. Even on hardware available in 2001, it was capable of handling landscapes with hundreds of trees swaying gently in the breeze, several dozen tribal buildings, and hundreds of individually tracked humans."
     
  8. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    Fair cop, though I hope you weren't using a general engine to do something like that anyway - the God view shouldn't have worms in the scene in the first place. :)
     
  9. zoombapup

    Moderator Original Member

    Joined:
    Nov 25, 2004
    Messages:
    2,890
    Likes Received:
    0
    I guess I should have framed this question a little better too. I'm trying to think through the ramifications of a large world space. Near/Far clip is one issue, obviously if you're talking vast open worlds, then need to be careful with the visible distances. I'm using a light scattering simulation to do a bit of that, but will play a bit more.

    One other thing I wondered about, if you guys have come across this. Is numerical stability at the bounds of the world. What I mean is that if you take the world origin at 0,0,0 and sail off in one direction, at some point you reach the numerical bounds of a floating point coordinate system. Anyone know how far that is? I don't mean theoretically, because I suspect things fail a lot faster than the theory, for instance my physics solver is likely to fail before reaching the bounds of floating point values.

    Just trying to find some ballpark figures. I guess I could make a quickie prototype to test it.
     
  10. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    You'll definitely need some sort of "local space" thing for the physics. Should be okay with frigging all the numbers based on a locality grid where the cell you're standing on is deemed the origin. Floats are surprisinly shit when you get down to it and even when centered around zero can start getting iffy pretty quickly - especially in simulations which are fundamentally unstable to start with.
     
  11. zoombapup

    Moderator Original Member

    Joined:
    Nov 25, 2004
    Messages:
    2,890
    Likes Received:
    0
    Yeah, I am trying to find a reasonable cell size for the world so that I can switch the transforms at the best rate. Its been suggested that the origin simply stays 0,0,0 at your character and the rest of the world transforms around it. But I don't think thats a good plan because that might mean you get failure at the boundaries (imagine a physics based barrel sitting on top of a landscape far off in the distance, if you only simulate based on local origin, then everything as it gets further away will eventually break down). I'm going to try and keep a local cell-space that is basically a cell of the world space, where everything is in the cells world-space coordinate system. Just wondering how big each cell can be. I mean I'm planning on generating much of the world content for a cell when the player is nearing a boundary anyway, so I'm wondering how big the space can get. I guess I'll do an experiment in unity and figure out my distances from there (luckily theyre using physx too and have the same world space unit setup as me).
     
  12. Gary Preston

    Original Member

    Joined:
    Aug 5, 2005
    Messages:
    239
    Likes Received:
    0
    Do you have a copy of game gems 4? There's an article on page 157 section 2.3 "Solving accuracy problems in large world coordinates" by Peter Freese (NCSoft). The solution he covers is using a floating origin. The example given at the start mentions a limit of roughly 1/2m accuracy at the bounds when you represent something 4.5km wide, although accuracy issues can show up elsewhere too.
     
  13. zoombapup

    Moderator Original Member

    Joined:
    Nov 25, 2004
    Messages:
    2,890
    Likes Received:
    0
    Thanks Gary, yeah I've got gems 4. Good article, think I might actually use his idea and see how it works. I already figured on using a segment:eek:ffset kind of thing, but not on dynamically changing the segment basis. Anyway, looks like some pretty useful info in there.

    Seems like the useful resolution of a typical physics engine doesn't go much beyond a typical FPS level before it starts getting errors accumulating. Who'd have guessed? :) Apparently Havok has support for changing the world origin basis, but Physx doesn't as far as I can tell.
     
  14. Tobias

    Indie Author

    Joined:
    Jun 13, 2006
    Messages:
    158
    Likes Received:
    0
    I remember Mad Skills Motocross spazzing out at 200 from origin. Changed to doubles instead and haven't looked back (better performance, takes more memory, must cast to float when rendering)

    If that didn't work I was planning on adding a float offset for each object, but then I'd have to update each position in the system whenever I update the offset.
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer