No announcement yet.

Unity5 How to optimize Speedtree drawcalls?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Unity5 How to optimize Speedtree drawcalls?

    For my scene i need to scatter a lot of tree objects. I just planted trees and have i lot of draw calls already. I have not even started to plant foliage. How can i combine trees objects to one mesh. Or set unity5 to batch trees to have a lower amount of calls. Or how can i optimize draw calls with speedtree. One speedtree tree takes 12 drawcalls! What if i what to plant 10k trees?

  • #2
    there are some tricks to boost the performance

    one of them: turn off the smooth lod in the inspector window

    Click image for larger version

Name:	smoothlod.jpg
Views:	1
Size:	44.4 KB
ID:	3006


    • #3
      12 draw calls in a tree is somewhat ridiculous. Is that a tree you made yourself? Usually for desktop models it is in the 3-5 range (branches, leaves, fronds/caps, and perhaps a second leaf type).

      You can affect the draw call count by how many materials per geometry type are used in a tree. Materials on the same geometry type are already batched together when the tree is atlassed (for example, 3 kinds of leaf meshes end up being 1 draw call). Also, adjust the LOD on the tree to drop things out, like caps and twig fronds. Then the lower LODs will have fewer draw calls.

      Billboards between multiple trees are batched together. So if you adjust your LOD settings appropriately, you can have a quite optimized forest.


      • #4
        At different distances I have a different amount of draw calls 20, 17, 14, 7 and 1 without tree. It just a simple tree with 3 LODs and 3 mats on each. YOu can see that on screenshots. I created a new project and nothing was changed. Default scene and default light.


        Click image for larger version

Name:	2015-04-27 17-17-56.jpg
Views:	1
Size:	96.1 KB
ID:	3007


        • #5
          Every shadow-casting light causes the tree to be drawn again into that shadow map, which will increase the count. However, even taking that into account, it seems like the draw calls reported for the tree are double what they should be. I will log to look into this.


          • #6
            Do I need to send you files?


            • #7
              Whats about huge amount of draw calls?


              • #8
                I have logged to look into it. We don't handle the rendering itself, so I will have to have some back-and-forth with Unity engineers to see if there is a problem.


                • #9
                  Thx a lot. I hope they will help.

                  I removed all weldings and got 1 branch material. Now I have 2 mat instead of 3 mat. I saved 1/3 draw calls.


                  • #10
                    I also have too many draw calls per tree. 26 draw calls for a tree with 2 LODs. What I don't understand is I have 5 materials listed for LOD 0 and they reference only 2 sets of textures/atlases (two reference a bark texture and three reference the same leaf atlas). In the Unity inspector, each are listed as a unique Geometry types which I'm guessing is part of the problem. Branches_0 and Branches_1 have the Geometry Type Branch and Branch Blend respectively. I also have Facing Leaves, Frond, and Leaf for the remaining Geometry types (all of which reference the same leaf atlas and the materials are identical in all other properties. (Imge1)

                    In Speedtree, I have been careful to use only 4 images textures (bark, cap, leaf branch and leaf card). I have not used any blended or detailed textures. (Imge2)

                    1) How can I reduce the number of materials that are generated out of Speedtree?
                    2) Beyond reducing the number of materials, how can I further reduce the number of draw call for a single tree in Unity?

                    Thanks for any input here!
                    AngieClick image for larger version

Name:	ToomanyDrawCalls.jpg
Views:	1
Size:	89.4 KB
ID:	3017Click image for larger version

Name:	ToomanySpeedtree.jpg
Views:	1
Size:	93.4 KB
ID:	3018


                    • #11
                      You have branch seam blending enabled on the branch material. That pulls out the blend parts into a separate draw call with separate material. Disable it, and you'll lose that draw call.

                      As I said above, every shadow casting light will cause the draw call count to go up since the tree has to draw in the shadow texture(s) and the main view.

                      I believe there has been some talk on the Unity forums about how LOD crossfade is preventing batching. You could try changing the LOD fade mode to see if it improves your draw call count.