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

Terrain performance problem

Discussion in 'General Graphics' started by MDADigital, Apr 21, 2020.

  1. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    Hi,

    I have a 512x512 meter terrain with these settings
    upload_2020-4-21_14-1-37.png

    Note that details are not drawing, plus there is no detail defined on the map. This scene take place well above the tree line in a mountain.

    For debug I toggle terrain on and off each secondf. And there i a huge difference with it on or off. Here its 2ms difference



    Here it eats half my frame budget


    in both cases Umbra (occlusion culling) hides most of the terrain. For example for the first example
    upload_2020-4-21_14-6-51.png


    Some profiling, you can see when I toggle on off the terrain

    On
    upload_2020-4-21_14-29-19.png

    Off
    upload_2020-4-21_14-29-58.png

    I have tried microsplat, etc, but these are shader solutions for when you have many textures on your terrain. I only have two textures and these solutions does not affect frame time sadly.

    Here are the frame times steamvr reports

    upload_2020-4-21_14-33-22.png
     
  2. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    I have also experimented with single pass/single pass instanced and draw instanced on/off

    Single pass - terrain draw instanced off

    Batches 143

    Setpass 45

    Single pass - terrain draw instanced on

    batches 109

    setpass 40



    single pass instanced - terrain draw instanced off

    baches 76

    setpass 45



    single pass instanced - terrain draw insstanced on

    batches 59

    setpass 40

    Doesnt affect frame times more than around 0.2ms
     
  3. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    Recorded some more here is a area were fps drops below the required 90 FPS because of the terrain

    upload_2020-4-21_17-33-45.png


    Terrain on
    upload_2020-4-21_17-34-27.png

    Terrain off
    upload_2020-4-21_17-34-59.png
     
  4. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    Almost entire scene is occluded, above 7ms frametime.

     
  5. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    It appears i'm fill rate bound, here I toggle render scale 1.0 to 0.5 and as you can see huge difference



    Any tips on how to benchmark which shaders etc are causing this?
     
  6. EyasSH

    EyasSH

    Joined:
    Aug 15, 2020
    Posts:
    15
    Did you ever get to the bottom of performance issues with terrain? I'm seeing similar behavior in 2020.1
     
  7. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    Nope, we haven't released this scene yet. Need to solve it before we do. Microsplat has a plugin that let's you convert the terrain into meshes, will try that and see if performance increases
     
  8. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    Unity's terrain has terrible CPU overhead. Ditch it and use a mesh instead.
     
  9. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    I tried microsplat mesh solution and the frametimes didn't change. Guess if I add LOD and maybe set a simple diffuse shade or similar in distance it might give a small boost.

    I increased pixel error to 15 and decreased maximum texture resulotion from 1024 meter down to 235 meters. This shaved off 0.5ms from the frame time
     
  10. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,728
    I see a few things that arent right:
    • Why isnt draw instanced on?.
    • Pixel error should be higher, like 100.
    • Base map dist should be less than your terrain size (512 x 512), (around 128-256), as you dont need to see/render the whole terrain.
    • Shut off two sided, casted shadows, shadows cost alot of performance.
    • Are you using reflection probes? If not, shut it off.
    • 128 for detail RPP, is a bit high, drop to 64 (its not noticeable visualy, but terrain is a resource hog/ and your not using trees/grass).
    • Occlusion Culling?
    • LOD's on objects?
    • Light flashing on control panel, in video #2, is causing your performance hit, (narrow it down).
    The rest looks solid, just squeeze out as much as you can do without, and not compromize visuals...
     
    Last edited: Apr 4, 2021
  11. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    Thanks for input! :D


    I have created a little benchmark solution were I can record a path in my scene and record frametimes. I'm on new hardware (Nvidia 3090 / AMD 5950x vs the old 1080 TI / AMD 3950x) so we cant compare frametimes with the old ones. But her are some number I have extracted. (in milliseconds)

    Original settings from first post:
    Highest Frametime: 4.373736
    Lowest Frametime: 1.972616
    Avg framerate: 2.912005

    Terrain disabled:
    Highest Frametime: 2.739844
    Lowest Frametime: 1.457568
    Avg framerate: 2.024579

    Cut hole terrain instead of just lowering were the military base is:
    Highest Frametime: 3.417968
    Lowest Frametime: 2.021404
    Avg framerate: 2.517401

    Cut hole and draw instanced:
    Highest Frametime: 3.517944
    Lowest Frametime: 2.02666
    Avg framerate: 2.596164

    Cut hole, draw instance off, pixel error 15, base map distance: 235 meters
    Highest Frametime: 3.283628
    Lowest Frametime: 1.918912
    Avg framerate: 2.40894

    I will see if I can increase it more. But after 15 that I have now I saw errors in terrain when moving around. Remember, VR headset have much bigger "screen" than a normal desktop monitor so details are blown up to much bigger proportions.

    Yeah, I changed that to 235 and thats as low as I can go without seing degrading in visuals. After cut hole that is probably the setting that did the biggest improvement. Why I cant go lower is because if you look down the mountainside you will see.

    I'm on baked lightmaps with a mixed mode directional light, I do not think that settings will do anything but will try and report back.

    I'm having one probe for the outside. But all indoor probes that happens to touch the terrain influence too. Maybe I can somehow make it so that terrain only use this one probe? Also there is a annoying bug in unity that makes indoor meshes use this outdoor probe even though the completely are inside another probe with higher prio than the outdoor probe.

    Will try and bench

    Yep its baked. But Umbra sucks and renders quite alot of the terrain even when its not visible by camera.

    Yepp. On all objects with any detail. Funny thing is. If I force lod zero using lodgroup.ForceLOD(0) on all lodgroups I get

    Highest Frametime: 2.850576
    Lowest Frametime: 2.015992
    Avg framerate: 2.323839

    The light isnt the problem, its a baked mixed mode light that I change intensity on. I toggle the terrain on and off in the video, the frametime change is 99% terrain. Since Umbra does not work properly alot of the terrain is rendered even though the camera sees none of the terrain. Cutting away unused terrain probably helped alot in this specific location.


    I will try your things and bench :D
     
    Last edited: Apr 4, 2021
    warthos3399 likes this.
  12. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,728
    Gotcha, all you can do is keep trying till you narrow it down... :)
     
    MDADigital likes this.