Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Split big terrain into smaller terrains

Discussion in 'Scripting' started by TheEnigmist, Jun 20, 2012.

  1. TheEnigmist

    TheEnigmist

    Joined:
    Jun 10, 2012
    Posts:
    51
    I have a question about terrains... i want to create a big map, so first i created nxn terrains wich size is 2000x2000. The problem i got is that each terrain has different height at the edge so i tried to make terrains seamless. I don't know how can i script this, so i tought, if i create 1 big heightmap am i able to split that heightmap in single terrains?
    I tried something but i didn't reach what i tought, can someone help me? :)

    PS: Each terrain is generated with a perlin noise script runned in realt-time, so i can't know what will be heightmap values!
     
    Last edited: Jun 20, 2012
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    [link removed. Site no longer exists]

    Not easily...terrain resolution must be power of two+1, so if you have e.g. a 1025x1025 res terrain, that can't be easily split since it's an odd number, so you'd need to fudge things. Same with 513x513 or any other resolution. The size (2000x2000) is not the same as the resolution.

    --Eric
     
    Last edited by a moderator: Dec 5, 2023
    Climber-fx likes this.
  3. karljj1

    karljj1

    Joined:
    Feb 17, 2011
    Posts:
    440
    The asset store has a nice terrain stitcher tool.

    You can get to the height data using the TerrainData class. Use GetHeights to get access to the height data, basically a big 2d array of floats. Compare the edges of the array to the edges of the neighbour array and attempt to smooth the values so they join.

    Your height data will have been interpolated into the terrain height map resolution, so dont expect it to be the same as when it went in. You may need to do some form of bilinear interpolation to convert between the original data and the unity height data.

    Karl
     
    Last edited: Jun 20, 2012
    JonasLuz likes this.
  4. TheEnigmist

    TheEnigmist

    Joined:
    Jun 10, 2012
    Posts:
    51
    Thanks you, i've alredy seen this. It is great, but i prefer to lern by myself how to solve the problem :)
    I will work on this. I know how set the height of a terrain edge to be the same of next terrain, but for the moment i don't know how can i interpolate that point with the alredy generated terrain ahah. I have to learn about Perlin noise more and interpolation between points...
     
  5. TerraSame1

    TerraSame1

    Joined:
    Nov 12, 2010
    Posts:
    151
    Eric5h5,
    Here is an FYI for you...
    I am soon to launch our Demo project and I have found use of your StitchScape....
    Thanks for your assistance and for your hard work with StitchScape.
    If you care to, you can see a vid and a couple of screens of out work at the post entitled "Whistler 3.5.3"
    The post is under "Showcase" / "Cool Images" the last post....
    When and if some cash comes in... some will make it your way....
    Thanks Eric5h5!
     
  6. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    1,199
    I have just released an editor extension that allows you take a big terrain and slit it into smaller pieces; it's called the Terrain Slicing Neighboring Kit and is available on the asset store for 5$. You can divide your terrain into 4, 16, 64, 256, 1024, or even 4096 smaller terrains. Trees, textures, etc are all replicated. Have a look at this forum post for more information: http://forum.unity3d.com/threads/163640-Released-Terrain-Slicing-amp-Neighboring-Kit

    If you're looking to do it on your own, it is possible to divide your heightmap, but only by a power of 2 (2, 4, 8, etc)
     
  7. Kos-Dvornik

    Kos-Dvornik

    Joined:
    Jan 3, 2012
    Posts:
    224
  8. Vagrod

    Vagrod

    Joined:
    Aug 4, 2017
    Posts:
    82

    Attached Files:

  9. darkAbacus247

    darkAbacus247

    Joined:
    Sep 7, 2010
    Posts:
    251
    Many thanks!!!! :)
     
  10. kantagara

    kantagara

    Joined:
    Sep 15, 2014
    Posts:
    15
    I'm doing the terrain splitting now, and we have some issues with it. The issue is that the terrain split is clearly visible when you run the game. I can't modify the terrain itself since we made it so that terrain splitting happens during the build process. Is there anything this can be solved with?
     
  11. darkAbacus247

    darkAbacus247

    Joined:
    Sep 7, 2010
    Posts:
    251
    use something like Terrain Stitcher, it works fairly well OOB - haven't had any issues with it anyway and its only 5$
    also offers a bit on top of other stitching services

    Keep in mind results very and are very much dependent on quality and use / so don't expect it to fix a brick, but if your terrains are slightly or even a bit off it'll do a really good job.

    Anyway, that's my two sense.

    https://assetstore.unity.com/packages/tools/terrain/terrain-stitcher-42671
     
  12. kantagara

    kantagara

    Joined:
    Sep 15, 2014
    Posts:
    15
    They are slightly off, I hope this solves the issue. Thanks!
     
    darkAbacus247 likes this.