Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Very low FPS from Terrains

Discussion in 'Editor & General Support' started by Ebolinux, Oct 13, 2014.

  1. Ebolinux

    Ebolinux

    Joined:
    Jan 23, 2014
    Posts:
    117
    Trying to figure out what is causing the huge drop in FPS.


    Have 16x terrains.
    Pixel Error 5
    Base Map Dist 25
    Terrain width & length & height 1000x1000x500
    Heightmap Res 513
    Detail Res 512
    Detail Res per patch 16
    Control texture 512
    Base Texture Res 128

    Tree & grass on them. Not a lot of other items.

    Get around 8-14 FPS

    I have gone through and systematical disabled and changed thing. To list a few...
    Changing quality does almost nothing
    Disable trees & grass does almost nothing
    Setting LOD's does almost nothing
    Tweaking setting does almost nothing.


    What does seem to change it is when the Terrain Colliders are turned off & the terrains them selves are disabled.


    Disable ALL Terrain Collider = 30 FPS
    Disable ALL the 'Create Tree Colliders' = 30-35 FPS
    Disable All Terrains = 94 FPS

    Any idea what may be causing this or how to fix it?
     
    Last edited: Oct 13, 2014
    ksam2 and BrandyStarbrite like this.
  2. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,068
    Wooah!
    How many polys or tris is your terrain?
     
  3. Ebolinux

    Ebolinux

    Joined:
    Jan 23, 2014
    Posts:
    117
    Where do i find that information out at?
     
  4. Ebolinux

    Ebolinux

    Joined:
    Jan 23, 2014
    Posts:
    117
    Is this what you are asking about?
     

    Attached Files:

    BrandyStarbrite likes this.
  5. Ebolinux

    Ebolinux

    Joined:
    Jan 23, 2014
    Posts:
    117
    When I uncheck ALL of the terrain 'Create Tree Colliders' the FPS goes up for 30-35
     
  6. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,068
    Yay!
    Thanks for the screen shot.
    Yes, you'll see "Tris" in the Statistics thingy.

    Gasp?! Tris = 2.2 million?
    And 2863 Drawcalls? :eek:

    Wooah!!

    This could probably be, why you're getting so much slow down for your game.

    I wonder what object/objects are using so many Tris?
    Nothing is wrong with having so many Tris, but something is a culprit here.

    By the way,........how many trees are in your scene?

    Do the trees in your scene have thousands of individual png. alpha leaves on them?
    If the answer is yes,..............those thousands of leaves on each tree, could be what is slowing down your game immensely. And raising the polycount so high.

    Same with the grass too.
    If you have thousands close to millions of grass strands, covering a large or semi large area, in you game, it could cause alot of slow down problems or crashes.

    I also noticed you have 662 Shadow casters.
    I'll have to check up on this shadow caster thingy.
    Since I don't know much about it.

    From my observation of the pic you posted, and from what you've told me.
    I'd say the leaves on the trees and thousands of grass strands are the cause of your slowdown problems.
    And could probably be why you have 2.2 million tris in your scene.
    And tons of shadows all over the place.

    Note: Texture Atlases are a good way to Super reduce Drawcalls.
    Less shadows are better too. (Literally)
    Less materials are better too.
    You could use lightmapping too for super big scenes.
    Most objects should share materials and share a texture atlas too.
    Giving you alot of room and power, to do all sorts of crazy cool things in your game.

    Be careful when using too much physics and particles in your game.

    Could you post a more zoomed out, distant pic of you scene, so I could see most of the objects in your scene.
    And the entire scene itself?

    By the way, nice pic. That scene is Lovely. Love the Greenery's!! :D
    I'll be back!
     
  7. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,068
  8. Ebolinux

    Ebolinux

    Joined:
    Jan 23, 2014
    Posts:
    117
    How many trees are in your scene?
    ruffly, 5000 x 16 = 80k ish

    Do the trees in your scene have thousands of individual png. alpha leaves on them?
    No, i dont think so.

    Same with the grass too.
    Yes, we have a lot of grass

    The gray blob on the right is from RTP fog.
     

    Attached Files:

    BrandyStarbrite likes this.
  9. Ebolinux

    Ebolinux

    Joined:
    Jan 23, 2014
    Posts:
    117
    I went to each terrain and deleted the grass and the FPS went up about 10-14
    Then I went and deleted all the trees from the map and the FPS went up to 35-45
    Then I disabled ALL terrains but one and the FPS went up to 95
     
    BrandyStarbrite likes this.
  10. Ebolinux

    Ebolinux

    Joined:
    Jan 23, 2014
    Posts:
    117
    Is there a good way to create Texture Atlases?
     
    BrandyStarbrite likes this.
  11. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,068
    Sorry for the long disappearance.
    Working hard for the past 2 months, and before that, Designing characters, for a game we're working on.

    It took a whole day today, to make a girl character today! GASP!!
    :eek:
    Finally found time to relax. :p

    Well to answer you question, normally texture atlases are made in drawing or 2d programs like Gimp and Photoshop.
    There are many many, tons of methods and ways to make them.

    I was reading this weeks ago, http://forum.unity3d.com/threads/texture-packer-unity-tutorial.184596/
     
  12. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,068

    Wooah! Lovely scenes dude.
    Nice and large.
    No wonder you're experiencing so much slowdown.

    Thanks for answering the questions too.
    Thanks for the info on the grey blob too.


    The grass is obviously one of the reasons why there is sooo much slowdown.
    Ther are supposed to be many tricks in the game design industry to fake them, using png. or long png. images.
    images.
    You could even get away with making an animated texture grass too.
    Wait.................are you using particle grass or animated flat 2d texture grass?

    For the trees,...............if you didn't read this, please do,........http://docs.unity3d.com/Manual/terrain-Trees.html

    Wow! Your scene is huge and nice. Very Lovely.
    So is your scene made up of multiple landscape parts, joined together to make one single large landscape scene?
    Or is it one giant big whole landscape?
     
  13. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,068
    Gasp!
    I hope you did that experiment to a test copy of your scene.
    And not the original.

    From what you've just told me,...............interesting.
    You said "terrains?"
    If you are using, multiple terrains to make one giant landscape, then the problem could be that the game is trying to render too many different parts of the large scene at the same time.
    And objects far off in the distance + all of the trees, grass and objects in your scene.
    That can be taxing.

    Maybe make the camera render parts/objects of the scene at a certain distance. Or what is in your camera view.
    eg. Objects or parts of the scene 10 or more meters from your camera view, should be rendered.
    And when you move through the scene, anything within 10 meters or more would be rendered as you move along.

    Or if your large scene is made up of different parts,
    eg. Beach part, Forest part etc.
    Make a script or trigger, where when you leave one portion of the landscape,
    eg. you leave the beach to go to the forest portion, as you reach a certain distance/closness to the forest, the forest part of the landscape and items in it are loaded into view.
    Some people might use a fake fog/png. fog or mist as a trigger, between the beach and the forest to do this.

    You could even put each portion of the landscape on different layers too.
    Less taxing for your PC etc.
     
  14. Ebolinux

    Ebolinux

    Joined:
    Jan 23, 2014
    Posts:
    117
    It was a combination of having a bunch of small terrains, a bunch of trees, and everything having colliders.

    I made ONE 4000x4000 terrain, added a bunch of trees, made it look really nice and Im getting 80-130 FPS.
     
    BrandyStarbrite likes this.
  15. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,068
    So you made one with a 4000x4000 terrain with trees and you're getting good frame rate?
    Interesting.

    This adds more to the mystery, as to why you're getting so much slowdown in your original large scene.
     
  16. Ebolinux

    Ebolinux

    Joined:
    Jan 23, 2014
    Posts:
    117
    Created ONE large terrain (4000x4000) of the exact same size size as the 16 old ones (1000x1000 each).
    Added a bunch of terrain trees and grass. And it runs like a charm now. Looks like in unity if you have a bunch of small terrains & trees & with the collides it gets REALLY slow. I have not tried adding prefab trees yet to see how that works.

    But using multiple terrains, terrain trees, & the terrain/tree colliders are defiantly what was causing it.

    - Editor is running SUPPER smooth & fast!!!!!
    In play mode in in editor...
    - With No trees we get 120+ FSP
    - With 7k trees we get 80-120+ FPS
    - With 10k+ trees we are getting 50-80+ FPS
    - RPT & UniStorm drop the FPS about -(4-8)FPS ish if that
     
    BrandyStarbrite likes this.
  17. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,068
    Nice. Thanks for that info. :D
    Glad to read that things are going okay on your game.
    And that you solved the FPS problem too.
    One of the posts I posted above, did mention something close to what you just told me.
    Nice. :cool:

    PS: When you said 4000x4000,......................were the units in meters?
     
    Last edited: Oct 18, 2014
  18. Ebolinux

    Ebolinux

    Joined:
    Jan 23, 2014
    Posts:
    117
    4000x4000 yes meters I think. Its the unity default measurement.

    What we also did was take all the terrain trees and turn them into prefab trees. Then we added LOD to the prefabs. I still need to tweak it a bit. But that increased the play performance another +40-50% on top of what we already had! I not tried doing scrip billboard yet. And the editor can get slow when you zoom in on the trees. But i think that's because i need to tweak it.

    C# code to convert terrain trees to prefabs. Tools > Custom > Terrain > just click button
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using UnityEditor;
    4. using System.Collections;
    5. using System.Collections.Generic;
    6.  
    7. [ExecuteInEditMode]
    8. public class CustomTreeBrush : EditorWindow
    9. {
    10.    private bool randomRotation = true;
    11.    private bool randomScale = false;
    12.    private float scaleMinValue = 0.9f;
    13.    private float scaleMaxValue = 1.1f;
    14.  
    15.    [MenuItem("Tools/Custom/Terrain")]
    16.    static void Init()
    17.    {
    18.      CustomTreeBrush window = (CustomTreeBrush)GetWindow(typeof(CustomTreeBrush));
    19.    }
    20.  
    21.    void OnGUI()
    22.    {
    23.      if (GUILayout.Button("Convert to objects"))
    24.      {
    25.        Convert();
    26.      }
    27.      //  if(GUILayout.Button("Debug"))
    28.      //  {
    29.      //  }
    30.    }
    31.  
    32.    public void Convert()
    33.    {
    34.      TerrainData terrain = Terrain.activeTerrain.terrainData;
    35.      TreeInstance[] treeInstances = terrain.treeInstances;
    36.      List<TreeInstance> TreeInstances = new List<TreeInstance>();
    37.      float treeRot = 0;
    38.      GameObject go = new GameObject("Trees");
    39.      GameObject[] gos = new GameObject[terrain.treePrototypes.Length];
    40.    
    41.      for (int i = 0; i < terrain.treePrototypes.Length; i++)
    42.      {
    43.        gos[i] = new GameObject(terrain.treePrototypes[i].prefab.name);
    44.        gos[i].transform.parent = go.transform;
    45.      }
    46.    
    47.      for (int i = 0; i < treeInstances.Length; i++)
    48.      {
    49.        TreeInstance myTree = treeInstances[i];
    50.        Vector3 treePos = new Vector3(myTree.position.x * terrain.size.x, myTree.position.y * terrain.size.y, myTree.position.z * terrain.size.z);
    51.      
    52.        if (randomRotation)
    53.          treeRot = UnityEngine.Random.Range(0.0f, 360.0f);
    54.      
    55.        GameObject tempTree = PrefabUtility.InstantiatePrefab(terrain.treePrototypes[myTree.prototypeIndex].prefab) as GameObject;
    56.        Transform nt = tempTree.transform;
    57.        nt.rotation = Quaternion.Euler(new Vector3(0, treeRot, 0));
    58.        nt.position = treePos;
    59.            
    60.        if (randomScale)
    61.          tempTree.transform.localScale *= UnityEngine.Random.Range(scaleMinValue, scaleMaxValue);
    62.      
    63.        tempTree.transform.parent = gos[myTree.prototypeIndex].transform;
    64.      }
    65.      terrain.treeInstances = TreeInstances.ToArray();
    66.    }
    67.  
    68. }
    69.  
     
    Autarkis likes this.
  19. Ronald_McScotland

    Ronald_McScotland

    Joined:
    Jul 30, 2014
    Posts:
    174
    Increasing Detail Res per patch really reduced the drawcalls in my game. It makes it batch larger areas of grass together. Try increasing it as high as you can.
     
  20. Ebolinux

    Ebolinux

    Joined:
    Jan 23, 2014
    Posts:
    117
    How do you do that?
     
  21. Ronald_McScotland

    Ronald_McScotland

    Joined:
    Jul 30, 2014
    Posts:
    174
    It's in the terrain settings, third setting from the bottom.
     
  22. DrSnake

    DrSnake

    Joined:
    Oct 17, 2014
    Posts:
    33
    Is occlusion culling working?
     
  23. Wolfdog

    Wolfdog

    Joined:
    Jun 22, 2014
    Posts:
    61
    This is really helpful. Thanks a lot!
     
    baskan379 likes this.
  24. Wolfdog

    Wolfdog

    Joined:
    Jun 22, 2014
    Posts:
    61
    Also, setting the Detail Density to something (slightly) lower will help a bit (without ruining the sight).
     
    Last edited: Feb 16, 2015
    DreamLoopTheGame likes this.
  25. ttmmiizz100

    ttmmiizz100

    Joined:
    Mar 16, 2018
    Posts:
    11
    HOW DO U USE THIS??