Search Unity

Technical question about really big terrain.

Discussion in 'Getting Started' started by tomy1971, Jan 24, 2020.

  1. tomy1971

    tomy1971

    Joined:
    Nov 21, 2012
    Posts:
    5
    Hi,

    I search everywhere but couldn’t find the answer.

    I have a very big map, if I could tell the distance in real world it would be over 100 miles
    and a character could take 30-45-minute just to walk across the map. It will be a top view game.

    The map is a grayscale heightmap 8192x8192.

    I could split it in part and put it in unity but I wonder if there a performance issue with this technic, I don’t want to lose terrain detail that much

    I know there more than one method to do this, but the thing I want to avoid is separate it in scene, I know that it would be the best performance method but I don’t want the user load all the time I want it to be much natural possible without less loading.

    So, my plan is to split my 8192 in 7 or 8 part and load it in unity.

    For those who had more experience witch method is better in gain of performance and detail, what would be the best method?

    Maybe I could use a plane as default map and create 3d model mountain and create LOD and put it everywhere across the map. Since it’s a top view, the field of view is short.

    Thank for your help.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    It is possible to do terrains that large in a single scene as long as what the player is looking at isn't going to be susceptible to the jitter you will get when getting far from scene origin (0,0,0), since when you center the terrain when you reach the far edges you're going to be +/- 80,000 or so on either the X or Z axis. That will mean Unity will be unable to precisely place objects at that distance from origin since the float type used in a Vector3 for position only has around 7 decimal places of precision. Small objects and fine animations will appear to jitter. Relatively large objects generally still look fine though.

    I do terrains around 100 miles across in my game too and have settled on subdividing into 100 individual terrains, so a 10x10 grid. Much fewer meant a larger chunk of the terrain was rendering in max detail even though much of it was far from the camera, which seemed to impact FPS. I just played with the sizes and 100 seemed a good middle ground between performance and insanity just eyeballing it. No idea what actual optimal really is though. You say your game is top down, so this might not even matter, but I've never tried that large of a terrain in as few as 7 or 8 total divisions, so I don't know if there is any limitation you may run into there.

    With a large flat world with objects implementing colliders far apart from each other I've found that setting physics to use Multibox Pruning Broadphase offered a significant performance benefit. You can also improve performance by disabling terrain colliders for chunks of your terrain which are impossible for players to actually reach. My game is a wooden sailing ship game, so I disable terrain colliders for the sea floor sections and for terrain far inland, and just keep colliders for terrain at or near the shoreline enabled. You may have similar areas in your terrain which can be seen by the player but not actually reached.

    My project has been frozen on 2018.2.21, so I don't know if the changes to the terrain and physics systems from 2018.3 and later change any of this, as I haven't use the latest versions with this size terrain yet.

    Edit: A note on shadows. My camera is set for a very large viewing range, and I was unable to get rid of realtime shadow jitter in this kind of set up. According to someone else's bug report Unity says this is fixed in the SRP, but won't be fixed in the legacy pipeline. I haven't tested if that is the case or not, I just disabled shadows as they aren't important to my game and I'm sticking with the legacy pipeline. Might not be a problem with a camera set up for top down viewing though, which I'd assume will have a much more "normal" view distance.
     
    Last edited: Jan 24, 2020
    JoeStrout and Bill_Martini like this.