Search Unity

Unaccountable performance issues using lightmaps and batching

Discussion in 'Editor & General Support' started by HevyDevy83, Feb 24, 2016.

  1. HevyDevy83

    HevyDevy83

    Joined:
    Jan 22, 2014
    Posts:
    12
    Hey folks since the performance got really bad with the latest Unity-version i tried to reproduce the cause for this by making a specific test-project to test our baking/restoring/batching-workflow with older unity-versions till 5.1.

    The result was, that while the amount of drawcalls and the batched drawcalls differ between the versions the overall performance (FPS-wise) is the same over 4 different Unity-versions (5.1.3, 5.2.2, 5.2.3, 5.3.2).
    The main problem here is that the performance is bad in all the versions. Just to give an overview about what the situation is:

    There are 4 scenes in the app
    - 2 of them use realtime-shadows
    - 2 of them use baked-shadows
    - 1 of each uses a preloaded prefab
    - 1 of each instantiates the prefab at runtime

    For the realtime-shadow-scenes the whole background is set to static in the prefab, for the baked scene we restore the saved light map on awake and combine the meshes ourselves by using StaticBatchingUtility.Combine.
    Every scene has one dynamic object (a cube or cylinder) that is casting a realtime shadow, so we can test if the mixed lighting.

    I tested the app mainly on an android device (Samsung Galaxy S4) that should have no problems rendering the scenery (The realtime-shadow-scene should be a bit slow but not too bad, since static batching is working, right?).

    The result is really disappointing to say the least:

    - The realtime-shadow-scene has a solid 8.5 FPS using 115 drawcalls (196 batched drawcalls - static)
    - The realtime-shadow-scene with the instantiated prefab has 8.5 FPS using 185 drawcalls (115 batched drawcalls - dynamic)
    - The baked-shadow-scene both have between 18 and 22 FPS using 161 drawcalls (0 batched drawcalls)

    For more testing i added a button to disable the realtime-shadows to see what the difference is there:

    - The realtime-shadow-scene with disabled shadows has 15.6 FPS using 78 drawcalls (96 batched drawcalls - static)
    - The baked-shadow-scene with disabled (realtime-)shadows has 26 FPS using 160 drawcalls (0 batched drawcalls)

    For all the mentioned tests i added the specific screenshots (see also the next messages), were you can see more detailed informations.

    As you can see it seems like the actual amount of drawcalls doesn’t indicate what the performance should be like (not to mention that 115 drawcalls should not result in 8 fps on a galaxy s4). The amount of drawcalls is all over the place and doesn’t seem to have a connection to the actual performance.

    The only way i was able to reach steady 30 FPS on an Samsung Galaxy S4 was to disable the terrain additionally to the realtime shadows. (I had around 50 drawcalls then).

    My Question now is. How can i make a scene like this working with an ok performance. The scene itself is really not that complex and using all the technologies at hand (static batching, dynamic batching, light mapping and the staticBatchingUtility) it should not be that hard to reach a satisfying result.

    I hope sharing this helps me finding a solution to this problem or at least gives me a better of insight in functionality of unity.
    I you have any questions feel free to ask.

    Best regards

    Chris

    PS. btw disabling only the terrain in the realtime-shadow-scene had the effect that the FPS increased from 8.5 to almost 20 (reducing the drawcalls by around 20), so the issue seems to be definitely related to shadowing + terrain.
     

    Attached Files:

    Last edited: Feb 24, 2016
  2. HevyDevy83

    HevyDevy83

    Joined:
    Jan 22, 2014
    Posts:
    12
    Screenshots showing the performance with lightmapping.
     

    Attached Files:

  3. HevyDevy83

    HevyDevy83

    Joined:
    Jan 22, 2014
    Posts:
    12
    And the screenshots showing the performance without realtime-shadows.
     

    Attached Files: