Search Unity

How to make large seamless terrains?

Discussion in 'Editor & General Support' started by Synaptix, Mar 9, 2010.

  1. Synaptix

    Synaptix

    Joined:
    Mar 8, 2010
    Posts:
    7
    Greets. I am wondering what is the most efficient way to make huge seamless terrains?

    Do I make ONE huge terrain/scene and work on it?

    Or do I make several small scenes and "stitch" them together?

    How would unity stitch large sceneries to pre-cache/preload the next scene (when triggered)?

    Script/example would be fantastic. Thanks. :)
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    you would make several terrains and stitch them together and you would likely not use scenes at all in this environment but Asset Bundles and code that dynamically loads stuff as needed.

    UniLOD on the showcase board might help within the single terrain range.


    You will though have to develop it yourself though and if you go the Asset Bundles way require Unity Pro (check what UniLOD offers out of the box though. haven't looked too much into it yet, just a shallow on the surface scratch)
     
  3. TrickyFishy

    TrickyFishy

    Joined:
    Aug 27, 2009
    Posts:
    39
    I have tried both. In the current version, Unity appears to be leaking (I think splatmaps) when you unload a terrain so if your terrain is really huge and you visit all of your terrain, you will run out of memory.

    I'm sure this will be fixed soon. Of course, maybe there is a trick to unloading terrain I don't know about.

    What I've done is create a quadtree data structure, and put my terrains into it. Then I monitor the main camera position and load/unload terrains based on querying the quadtree.

    I haven't got all the bugs worked out but I think will post the source to it soon. Here is a video of it in action:

    http://www.youtube.com/watch?v=XLOxU-JxDds
     
  4. Synaptix

    Synaptix

    Joined:
    Mar 8, 2010
    Posts:
    7
    That looks fantastic!

    * So all the "chunks" you are loading in are seperate scenes?

    * Or a very large scene cut up into chunks?

    * Can this be infinitely "stitched" via infinite seperate scenes?

    * Is the code complex? You mention on youtube you will be cleaning and releasing it. Any time soon? :)

    Thanks.
     
  5. TrickyFishy

    TrickyFishy

    Joined:
    Aug 27, 2009
    Posts:
    39
    Each chunk is a Terrain instance, not a scene. What you would do is make the terrains AssetBundles and stream them in on a background thread. I don't have this part implemented. At the moment, the terrains are simply instantiated prefabs.

    The terrain was generated in L3DT outside of Unity. It will generate very large terrains and output heightmaps split up into smaller chunks. I have a script that imports all of these and generates individual textured terrain prefabs.

    That is how I end up with lots of seamless terrains.


    Infinity is a big number :) L3DT's current limit for heightmap size is 128k x 128k pixels which is HUGE and takes over a month to generate. With this split up into 512 pixel heightmaps, you get 256 terrains in each direction. L3DT can make the heightmaps wrap around so each end is perfectly seamless so you could just wrap around your world.

    It's not that the code is complex, it's just not quite ready for general consumption. It's a bit specialized for my purpose, has stale code commented out and is generally a bit of a mess. :D

    I definitely want to share it though because I've gotten so much from others here.
     
  6. Synaptix

    Synaptix

    Joined:
    Mar 8, 2010
    Posts:
    7
    Is there a specific format for those chunks via L3DT? Or can any other program be used to generate such terrains? ie is it purely rendered graphic files (eg TIF TGA's) or are they specific data files that L3DT exports?

    Also, do we even need external programs? Can we not just save several scenes from Unity and stitch them via your code? Or are they just stitched heightmap-renders?

    What about flora/fauna and other architectures? How do you import in custom zones with your code?


    Using your code, even with 128k x 128k, cant you append "another" 128k x 128k at each end and so on (ie technically infinite)? (Naturally you would wish to manually bottleneck/restrict edge-tracing players into certain guided zones so they are not always wandering off forever.)

    Cant wait! Thanks for sharing. :)

    PS. I see the TornadoTwins are your fans too! :)
     
  7. TrickyFishy

    TrickyFishy

    Joined:
    Aug 27, 2009
    Posts:
    39
    No L3DT can export in the RAW format that Unity uses. What I use is L3DT's attribute map which determines what textures to place where. This is not a format Unity uses and Unity doesn't expose in the GUI a way to apply the splatmap. Tom's terrain tools will let you do this. You can export a color-mapped PNG from L3DT and use Tom's tools to apply the splat but you would be limited to 4 textures. I am using 8 textures so I use L3DT's native AMF format and apply the textures based on that data.



    No you don't need any external programs but creating terrain by hand is tedious. There are some new terrain tools that Unity just released: http://unity3d.com/support/resources/unity-extensions/terrain-toolkit that are helpful. My code doesn't do any stitching of terrains. You have to do that yourself. My code only decides which terrain to display.

    Not sure what flora/fauna are.

    As far as appending "another' 128k, the quadtree data structure needs to know the full size of the partitioned space ahead of time. If you change the size, you have to repartition, which isn't a problem I guess.
     
  8. grfxman

    grfxman

    Joined:
    May 28, 2009
    Posts:
    309
    Did your code ever get posted anywhere ? :)

    I would like to check it out
     
  9. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    I too would be interested in this dynamic terrain thinger - messy code or not! :p
     
  10. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    +1 I'd enjoy a go at this cool script
     
  11. Achim

    Achim

    Joined:
    Dec 19, 2007
    Posts:
    199
  12. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    @Achim - thank you!

    Although I'm actually looking to stich meshes together, not terrains(where the vertices overlap).

    I'm vaguely aware of a method, but could use help with a script direction to put this into action. Here are the steps I'm aware of, but am not sure how to implement:

    It will work something like this

    1: Get all meshes you want to combine
    2: Extract relevant mesh data (verts, normals, UVs whatever)
    3: Combine mesh data into new arrays
    4: Loop through combined verts, and check to see if any overlap
    5: Flag overlapping verts and remove them from all arrays, in the case of triangles, you'll have to be careful.


    Any help anyone can offer is greatly appreciated.
     
  13. The-W-A-T-Z-R

    The-W-A-T-Z-R

    Joined:
    Apr 13, 2014
    Posts:
    22
    hey i have make a big world. and the game ide is mmo,fps (**PC standalone**)
    I just want to point out that I'm not super good at English so be nice to me ^^
    and i'am so far noobY to uity

    I have this terrain that I want to avail myself of.
    info:
    Width & Length 20kX20k : height 2010 : heigtmap resolution 4097 : detail resolution 1024 : detail resolution per patch 8.VIDEO

    I also use the floating original script in my scene.
    i think you see what i am trying to do, i basically need so my character camera is close on the origin in the space world all the time, that works whit the script floating original. and the terrain is huge so i need to split it in to "chunks" so i can load and unload this "terrain-chunks-parts" that is in my field of view.
    somthing LIKE THIS Video or LIKE THIS and i knowe that i gonna use the LOD script or something similar like occlusion culling later :)

    PS: i use UNITY FREE

    so what i wonder is how do i split this terrain i have into square "chunks" ? for it is this terrain/map i whant to use.

    do i need to do my terrain how i want it (for i still need to edit my terrain more for my roads and city/town gonna fit the way I want it) and then take the terrain in to a thread program (3D-modeling program) and make it in tiles and then add it in to unity again but like a object or how does it works?

    I almost even thought to ask if someone can do it for me and get $50 :p. have been looking and looking but can not find any tutoriols to a easy way to do it :confused:, and it feels like it is way over my head, but i need it to be done. This is the hardest stop for me.

    and another question belonging to this a bit, which programs is there that i can use which is similar to the occlusion cullingthat are free or atleast works for UnityFREE it does not need to be free as long as it is cheap :)

    Thx in advance for your reply.
     
  14. Graham-Dunnett

    Graham-Dunnett

    Administrator

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    Please don't bump a three and a half year old thread *and* post a new thread.
     
  15. juggalofromtupelo

    juggalofromtupelo

    Joined:
    Sep 19, 2016
    Posts:
    1