Search Unity

Question [Solved] Universal RP Static Batching

Discussion in 'Universal Render Pipeline' started by tosdik, Aug 17, 2020.

  1. tosdik

    tosdik

    Joined:
    Mar 5, 2018
    Posts:
    6
    Hi I want to use static batching in my game with URP but it is not working as good as standard render pipeline.

    Is it a bug or am i missing something?

    Here some screenshots with 20k static cubes and GPU instancing enabled material:

    Static Batching with Standard.png Static Batching with URP.png
     
  2. Oxeren

    Oxeren

    Joined:
    Aug 14, 2013
    Posts:
    121
    As far as I can tell, you're looking at the statistics in editor mode, not in play mode. Static batching happens only in play mode. And static batching is incompatible with GPU instancing and overrides it when enabled. More than that, since you're using URP, you probably have SRP batcher enabled. As I understand it, it actually overrides GPU instancing, even if it's enabled in the material, since it is generally faster, except for cases like this where you have huge amounts of the same mesh with the same material (if you disable SRP batcher in pipeline settings you will see that batch number is reduced). Static batching should work though, but you will only see reduced batches after entering play mode.
     
    laurentlavigne likes this.
  3. tosdik

    tosdik

    Joined:
    Mar 5, 2018
    Posts:
    6
    Turning of SRP Batcher is worked for me Thanks alot!
     
    Jefferyzhou likes this.
  4. CianNoonan

    CianNoonan

    Joined:
    May 19, 2017
    Posts:
    139
    Why do you want to turn off the SRP batcher and turn on static batching, you can see your frame rate is significantly higher with the SRP batcher enabled. 56 vs 82 FPS. Static batching isn't always necessarily the best idea.
     
  5. Sky77

    Sky77

    Joined:
    Jan 30, 2014
    Posts:
    171
    If I understood it correctly, you can use static batching and SRP Batcher together. Static will be used first, then SRP it the object is not flagged for static batching.
    We still need to profile, but with this setup we have very good results.
    We’re not using instancing and we’ve disabled dynamic batching.
     
  6. CianNoonan

    CianNoonan

    Joined:
    May 19, 2017
    Posts:
    139
    If you have few shaders I'd honestly be surprised if static batching is doing much, it tends to generate huge unwieldy meshes. Please do profile and reply though, I'd like to see the stats
     
  7. Sky77

    Sky77

    Joined:
    Jan 30, 2014
    Posts:
    171
    Yep, we’ve not profiled yet because we’re getting very good performances all around.

    We’re using quite a few complex shaders in a very complex scenes, pushing around 800k polygons per frame, at 30fps on mobile, with various post process on (bloom, ambient occlusion, tone mapping etc...).
    We’ve a lot of static geometry for our env: I can try to disable static batching and try to use SRP Batcher only to see if there’s an improvement. :)
    I must say we’re very impressed by the results and performances.

    BTW, we’re on iOS only, working on devices from the 6S on, and we’re on 2020.2 + URP 10.

    We’ve seen huge performance improvement on URP moving on 2020 from 2019, and the 2020.2 + URP 10 is a bit more faster too.
     
    laurentlavigne likes this.
  8. CianNoonan

    CianNoonan

    Joined:
    May 19, 2017
    Posts:
    139
    I think in 2020(URP 9 I'm referring to) they refactored a lot under the hood, you can see it now requires burst etc.

    I'd say give it a go, especially on mobile having a huge dense mesh could be giving you more trouble than just drawing the meshes
     
  9. Sky77

    Sky77

    Joined:
    Jan 30, 2014
    Posts:
    171
    Absolutely, thanks for the advice! As I said, we’re still not at the optimization part since performances were already very good.

    Yep, they really improved performances a lot on URP in 2020, it’s a lot faster than in 2019.
     
  10. DonCornholio

    DonCornholio

    Joined:
    Feb 27, 2017
    Posts:
    92
    Hi!
    Would you mind giving an estimate of how much your rendering performance increased by upgrading to latest unity&urp? Do you know where the improvements came from (CPU/GPU)? My team is thinking about upgrading from 2019, but there might be quite some work involved. Would be great to have more info for a guesstimate if it's worth it or not. Thanks in advance :)
     
  11. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    Interesting feedback, that must depend on the target platform because I noticed very little improvement on Switch.
     
  12. PieterAlbers

    PieterAlbers

    Joined:
    Dec 2, 2014
    Posts:
    247
    Sorry for bumping this thread - but we're experiencing huge performance loss when upgrading to URP 10+ (coming from 2019.4 to 2020.3)

    I also am confused on the static and SRP batching. For us enabling SRP batching will disable all static and dynamic batching. Disabling SRP will enable them again.

    I can't find if they are 'allowed' to work together at all?
     
  13. Brother_77

    Brother_77

    Joined:
    Feb 8, 2019
    Posts:
    233
    Same issue 2020.3

    Shows that saved by batching is 0 and in the frame debugger the draw calls are the same number as the objects in the scene even though they share the same material and are marked as static.
     
  14. o1o101

    o1o101

    Joined:
    Jan 19, 2014
    Posts:
    639
    Based on the docs, I believe the queue is meant to be Static > SRP batcher > dynamic batch, personally I would love if they let us define the queue. Also judging by OPs posts, the SRP batcher was interfering with static batching for whatever reason regardless of the queue.

    SRP batcher is currently unusable for my case but maybe it could be viable if it was used as a backup when all else fails.
     
  15. Brother_77

    Brother_77

    Joined:
    Feb 8, 2019
    Posts:
    233