Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Increase Terrain Performance

Discussion in 'Editor & General Support' started by Hawk0077, May 10, 2018.

  1. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Hi, I have a 64 tile world creator terrain. Each tile is 512x512. Resolution 2048 each.

    I am also using megasplat on the terrains but megasplat doesnt really cost anything at present with the 2048x2048 sized textures as far as I can tell.

    When the scene is in playmode without the terrains active the FPS is approx 240-250.

    When I activate the terrain the FPS goes down to 44-50 which basically leaves no room to add anything else.

    I have actually added most scene objects with aquas water and the scene goes down to 11-15 FPS.

    So my question is what can I do to improve the performance.?

    Any suggestions welcoma dn appreciated.

    Thanks.
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,589
    First you need to find out what exactly is costly. You do this by creating a build, run it on the target platform and connect Unity's Profiler to your game. The Profiler shows you how expensive a certain code-path / feature is.

    Once you profiled the game and the Profiler told you what is expensive, you can use this information to start optimizing things.

    Here are a few resources that should help you to get started with the Unity Profiler.

    Learn how to diagnose common performance problems and optimize your projects:
    https://unity3d.com/learn/tutorials/topics/performance-optimization

    Introduction to the Profiler


    Unite Europe 2017 - Practical guide to profiling tools in Unity


    Unite Europe 2017 - Performance optimization for beginners
     
  3. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Awesome, @Peter77

    Much appreciated. I'll dig deeper into this now I have a direction.

    Thanks again.
     
    Peter77 likes this.
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    If you can afford to wait a bit for it to release, Unity have done some serious optimisations for this kind of multi-terrain workflow due sometime in 2018. 64 terrains is a lot for the old terrain system but probably fine for the new. It would mean moving to a new version of Unity and that's somewhat destructive though. Just adding peripheral information, as Peter's answer is great.
     
    Hawk0077 and MadeFromPolygons like this.
  5. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,967
    Just building on the 2 great answers here, once you have profiled and optimized as far as you can, look into some kind of asynchronous chunk loading/unloading based on distance, so that only max of say 9 tiles around camera are actually active.

    If you cant see it, dont draw it (and probably dont run its behaviours too unless it is something that you wish to continue simulating off screen) :)
     
    Reahreic and Hawk0077 like this.
  6. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Thanks, I am actually in no rush as I am really just getting the foundational terrain and main cities and objects etc in place "as I want them to look" before optimizing on a much deeper level after learning more.

    Also I was actually iunder the impression that advanced developers such as World Creator developers would have taken what you had to say into account before offering a product marketed as multiple terrains and their current limitations of basically zero. But as mentioned I dont know the ins and outs of unity etc so there are most likely IFS and BUTs I dont understand.

    Thanks again for the great input. Much appreciated.
     
  7. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    I
    I will, thanks. Glad I got answers that were extremely helpful too and that put me on the right path rather than going blind on my own. Much appreciated.

    So far I have just been looking at Occlusion Culling which hardly makes any difference if any.... and World Streamer which I put off buying because I really cant learn stuff whilst watching a detailed and unfocused screen whilst bad 90s thump music is going on to further distract me. But that's a pet hate of mine, " Great developers who don't have a microphone" (even bad english is better than none, that actually gets me more focused on what is being said. I say that because many developers seem to be Spanish, Dutch, German etc...)

    Again thanks for the advice.... I most definitely will take it and the other great comments here. Much appreciated.
     
    MadeFromPolygons likes this.
  8. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,967
    I mean 512x512 is 512 metres squared, and then you have 64 of those (32 768 m2 - a potentially insane amount to load at once or even in quarters, to put it into perspective you are trying to load and draw the entire map of skyrim in one go - skyrim was around 37000m2). A chunk in a game is usually something like 50 metres squared (and you load 9 of those around your camera), to give you some idea of the kind of optimizations needed to make this work. World creator will probably never be optimized enough to get this running with good performance out of box, its not really a performance issue as much as you need to learn to break up the data in your game into easy to manage and read in < > out chunks.
     
    Hawk0077 likes this.
  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You should lay off using any asset store assets for terrain really IMHO if there's no rush on this. Unity do have big improvements coming down the pipe.
     
    Hawk0077 likes this.
  10. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    I recently read a post dates 2013/14 about a supposed unity terrain upgrade that was at the time 4 years late?

    Is the update you speak of coming this year?

    Thanks
     
  11. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yeah it's this year. Unity will spam the blog ultra hard. I'm estimating it'll be late this year, during 2018.3 as a beta thing. I don't have clue honestly. It's based on what Unity showed at GDC.
     
    Hawk0077 likes this.
  12. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Thanks for the input. Much appreciated. Have a good one.
     
    hippocoder likes this.
  13. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    Just a few notes regarding tile-based worlds and high resolution terrain objects, you will never gain practical performance with high number of tiles and high-res heightmaps/textures on terrains in a static scene. Not in Unity nor in any other real-time 3D engines.

    We also wanted huge worlds with detailed terrains while maintaining performance in real-time and that's where we ended up releasing the streaming system in TerraLand. In the following video the total resolution for the heightmap is 16384 pixels and 65536 pixels for the imagery. The world is a 160 x 160 km area and the whole database size for the streaming server is about 1.5 GB.

     
  14. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    But that's exactly what a large number of games do including horizon zero dawn - which is an impressive piece of open world tech. Terrain divided up into 64 tiles of high res heightmaps, which directly goes against what you are saying. Perhaps they use compute and other techniques?

    I think we need to define what scales we are working at to comment, really. From your video perhaps you're talking about flight sim scales :)
     
    Hawk0077 likes this.
  15. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    My thoughts exactly.

    But I would probably be better off just listening as my knowledge is far too little.

    I actually cant get my project to build in order to profile due to texture size issues and so need to learn about Asset Bundling before I return to the terrain issues.

    AND... keep my unity version upgraded to the latest as I await the new terrain system.

    I will though do another multi tile terrain so I can test now I have a small amount of knowledge of where I will be going

    Thanks again, much appreciated for the input.
     
  16. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    You missed one point in my explanation and that's the word "static" there, of course you can possibly have unlimited resolution for your data but in a dynamic streaming environment as in our streaming system. That's why there are tiles in HZD to load/unload (or maybe intense LODing) them based on player position and why I shared the video at first place which is what OP asked for.

    But what you said about the scales is true, you can have a 160km2 area in a 16k heightmap or a 1 km area in the same resolution.

    In the video I posted, the whole world is a grid of 32x32 with each tile at resolution of 512 for the heightmap and 2048 for the textures loaded and streamed dynamically and obviously will explode your computer if run statically in the game start at once, not to mention that the base world is still empty.

    Also regarding the flight sim you mentioned, that's exactly where it becomes trickier as the "viewing distance" is the
    most important factor when dealing with huge open-worlds as it's harder to fill in the horizon when you are up in the sky rather than walking on terrain surface. In a flight sim you can not hide further tiles behind other elements and they are always in view plus your vehicle usually travels faster and streaming is done more frequently.

    P.S. I remember a dev talk of Horizon Zero Dawn where they said, we did not care much about the world size and metrics and that's the density and diversity of the elements in the game design which matters, while other games arguing about the map scale and at its best they mention it is a 16x16 km area but "sparse". The denser the scene is the more sense of scale and illusion of bigger space in perspective.
     
    Hawk0077 likes this.
  17. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Isn't streaming the same as occlusion culling?

    I tried occlusion culling and when visualized it streams each section as it should and looks like about 10% of the tile areas are active at any single time YET.... it makes absolutely no difference to the FPS.?????

    I also just did a test as follows

    1 - A 5760x5760 (4x4x1440/16 tiles) terrain.
    2 - A single tile 5760x5760 terrain.
    3 - A single 512x512 tile terrain.

    I used world creator as well as the standard unity terrain builder...

    I even flattened each and there was no visible FPS difference???

    And on ultra with v-sync active settings every single one of the above averaged around 66-76 FPS.

    That tells my unknowledgable self that unity is unusable. Add aquas and your done... An ignorant remark I know but you get what I am saying I'm sure.

    In short as a none experienced none developer I like to get the tools and then find my way around the issues but as yet I cannot find a way around the FPS issue which all begins with the terrain itself.

    Again, to my inexperienced self I was thinking of trying world streamer but it seems to me that all that does is something very similar to occlusion culling which as I mentioned doesnt work???
     
  18. roxIndie

    roxIndie

    Joined:
    Oct 14, 2012
    Posts:
    28
    The Unity terrain system is outdated and lacking for sure, but the troubles you describe here are things you would encounter with all engines. To do huge terrains you need to be really smart about how you do it, or it will be doomed to fail.

    Horizon ZD, TCGR Wildlands, Assasin's Creed, etc all use elaborate streaming systems, combined with heavy LODing and lots and lots of deterministic procedural generation. It is not easy, but with experience you can make it work on basically every engine. Before trying this you should think long and hard on whether this feature is absolutely necessary for your core game play!

    And occlusion culling is very different from streaming. Culling is just about what you render, while streaming is about what you actually load, and at what resolution.

    And about flattening terrains; heightmaps are converted to a mesh with a certain mesh "budget", to ensure stable frame rate while rendering, so it is normal that flattening the terrain don't make it cheaper.
     
    Hawk0077 likes this.
  19. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Thanks, much appreciated for clearing that up.

    Because I don't currently have the knowledge or experience to make it work, which subjects do I need to research in particular in order to get it working?

    At the moment the projects ready for dumping and using unity for what its actually geared up for out of the box. 2D or 3D 20x20 scenes.?

    Apologies for the sarcasm but I bought into the idea that creating a game can be done by the inexperienced? You don't need to be a C# Developer etc and so spend a couple of thousand so far in assets. Which I should have not been so naive about. My bad!.

    Following on from my above comments I am not sure what you mean here as I am trying to create what I believe to be a SMALL (4096x4096 JUST 4x4km square?) open world game of which the terrain is the foundation but the terrain demolishes the building of anything on top of it?

    I realize my own ignorance which is why I am asking these things in the first place.

    Thanks again for the input.
     
  20. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    Did you ever watched the video I shared and read through the description?

    Also the last 2 minutes of the video shows the streaming in editor to reveal what is behind the scenes as it dynamically streams/feeds terrain data from an external local server outside Unity similar to asset bundles.

    For the rest of the questions whatever @roxIndie said is true.
     
    Hawk0077 likes this.
  21. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Thanks again for the response. Yes I did watch the video you added but I didn't actually get the purpose/benefit of it as it just seemed to show WHAT I need to do and not HOW I can do it which as mentioned is beyond me at present. I will watch it again to see if I am missing anything
     
  22. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    =>>
    That's the benefit and purpose :)

    For this you need to have TerraLand 3 and follow this tutorial:

     
  23. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    II don't get it. It doesn't make logical sense.

    If based on my earlier experiment:

    1 - A 5760x5760 (4x4x1440/16 tiles) terrain.
    2 - A single tile 5760x5760 terrain.
    3 - A single 512x512 tile terrain.

    How is having 9 (of only 64) tiles more performant.

    If a single tile 512x512 gives no better performance than 12 1440x1440 tiles.... How can having 9 tiles loaded be better? More performant?

    Seems like just a better way to get a bad result?

    Plus isn't that for real world examples? Mine is fictional/self created terrain.
     
  24. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    This year, Unity will be rolling out terrain performance increases as well, specifically around managing a lot of tiled terrain chunks.
     
    Hawk0077 likes this.
  25. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Thanks again hippocoder, I thought if I can get it better now then it would surely be better still when the updates come.
     
  26. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    I've been working on a multi-tile setup as well, and would love to just sit tight and wait for Unity's improvements...but I can't wait until 2018.3 I haven't seen anything more specific than "Improvements coming in 2017.2....no, wait, not until 2018.3 maybe" -- is there more info anywhere that I've missed?

    EDIT: And what little I've heard sounded like it was for high-end games, not necessarily suitable for average (or mobile) hardware.
     
    Hawk0077 likes this.
  27. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    No, blog will show it clear as a bell.
     
    Hawk0077 likes this.
  28. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    Man, are these numbers terrains' sizes or heightmap resolutions? I guess you were playing with us because these numbers don't seem to be resolutions at all! :D
     
  29. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    No they were terrain sizes. I actually thought that was evident in the X, or 512x512 etc.

    The point is... Am I missing something? Can your terrain system solve the issue? If so how? Does it use a LOD system for the tiles etc? And will it work using my own heightmap RAW file/or World Creator?
     
  30. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    I'm sure many here thought you are referring to resolutions instead of sizes of terrain objects.

    Note that terrain(s) physical sizes has nothing to do with performance, that's the resolution parameters in the data which affect performance.

    Go to the Settings tab on your terrain object in scene and play with the settings and read the documentation to get started. You still have to learn the basics and then start to experiment with different settings. Following is a screenshot of the Settings tab of a terrain object in hierarchy, I've specified the parameters which affect the performance more.

    TerrainSettingsPerformance.JPG


    Remember that this only applies to that particular terrain parameters regardless of other scene settings which is relative to each other and also everything else in the scene plus project settings. So measuring the final performance depends on many factors in the environment.

    The Streaming system in the video shows that the system spreads terrains' data into tiles to maintain the performance by having a limited amount of tiles to process instead of having all the data processed each frame.

    The LOD system is built-in on terrains by setting the "Pixel Error" value.

    Yes, it works on any user-customized terrain data (heightmap, imagery, textures, splatmaps, materials) as shown below which is a tutorial on how to make a streaming system out of World Machine renders:

     
    mrtenda and Adunato like this.
  31. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Th
    Thanks for that info. Il process it and take a loo at the video later today as I am updating unity and the issues this incurred. Thanks again. I am taking a look at all the tips in this post to be honest so will start after the update of unity with your tips.
     
  32. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    Welcome, keep the questions coming as you go further ;)
     
  33. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Oh, I will. lol. I may get annoying to some as I dig deeper into this and more so when I eventually begin to learn C# which I am actually dying to do but wanted my terrain and main scene in place first.

    Thanks again.
     
  34. Lesnikus5

    Lesnikus5

    Joined:
    May 20, 2016
    Posts:
    131
    Hello! Is there any news about the improvement of the terrain system? I did not find any mention of this in the roadmap.
     
  35. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It's scattered all over the forums, but Unity has implied that there will be an announcement soon about this, keep an eye on the blog. I am excited!
     
  36. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    What's going on when stuff pops in and out?
     
  37. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,247
    That's when we need level designers in the project scene.
     
  38. DCIPRO

    DCIPRO

    Joined:
    Apr 11, 2019
    Posts:
    4
    I realize the age of this post may make any additional advice immaterial but there is a product called SECTR by Procedural Worlds on the asset store which allows you to load and unload resources as needed (virtually allowing for an infinite world full of assets). I am not associated with the creator, however, I am a happy customer...
     
    Hawk0077 likes this.
  39. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Since 2018.3 came out the terrain has been much better, getting 24-70fps. I recently completely restarted the whole project and so will bare SECTR in mind. Thanks for the response by the way.