Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

How does Unity engine partition levels?

Discussion in 'Editor & General Support' started by BigZee, Sep 5, 2007.

  1. BigZee

    BigZee

    Joined:
    Feb 18, 2007
    Posts:
    13
    Hey all,

    Just wondering, what method does the Unity engine use to partition a level. for example, I want to create an entire level for, say, a racing game that would consist of 500,000 polygons or more. Obviously, not all of them will be visible on the screen at any one time. What does Unity do to draw only the polygons on screen? Portals? OctTrees? BSP?

    Any info would be nice.

    Thanks!
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,749
    Rendering-wise, it's not (strictly speaking) partitioned, it's just that objects outside the camera's far clip plane are not rendered.

    It's easy to set up a partition system using trigger colliders and SetActiveRecursively, if you have more specific needs (like looking farther straight down the raceway than you need to be looking to the side of the track)
     
  3. bronxbomber92

    bronxbomber92

    Joined:
    Nov 11, 2006
    Posts:
    888
    I asked this once, and Aras told me "We cull the scene, and make it really, really fast". Or something like that :roll:

    Don't worry, it's going to be fast :D
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Well, that depends on what you're doing. Sometimes you don't want to rely on just the built-in culling, which is view frustum culling. For example, if you're doing an indoor game with a lot of rooms, it doesn't make sense to render those rooms that you can't see just because they're also within the view frustum. However, this is exactly what happens now. Fortunately it's not hard to implement your own solutions for things like portal culling, using triggers like StarManta said to turn off objects you can't see.

    A racing game would probably be fine with just view frustum culling. Just make sure to keep the view distance sensible, and maybe implement some kind of LOD system depending on what sort of stuff you're drawing. The upcoming terrain system in 2.0 might make this easier depending on what sort of racing game you're doing.

    --Eric
     
  5. bronxbomber92

    bronxbomber92

    Joined:
    Nov 11, 2006
    Posts:
    888
    I bet Unity implements a system where they also don't render polygons that are behind other polygons. I'm thinking that's the "really, really fast" part means.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Actually, it doesn't. (And yes, that's a fact. ;) ) That would be kind of hard, and also not what you want a lot of the time. (For example, you need objects to be drawn behind other objects in case you're using transparent textures.)

    --Eric