Search Unity

Why Aren't These Two Batches SRP Batched Together?

Discussion in 'General Graphics' started by cassius, Jan 17, 2021.

  1. cassius

    cassius

    Joined:
    Aug 5, 2012
    Posts:
    125
    Why are the two sets of batches in the attached images not batched into a single SRP Batch? Right now I'm seeing about 80+ SRP Batches in Render Opaques -> RenderLoopNewBatcher.Draw.

    In fact I have a lot of SRP Batches that aren't batching at all, or are batching just a few, when I expect dozens of batches in them - all things (that I can see) being equal.

    Unity 2019.4.11

    Image1: 43 batched calls for "banners"
    unity_SRP1.png

    Image2: 45 batched calls for "banners". Same prefabs as above, same shader, same reflection probe,etc.
    unity_SRP2.png

    This is just one example of many in my scene. I would have expected closer to 20 SRP Batches rather than 80+.
     
  2. BattleAngelAlita

    BattleAngelAlita

    Joined:
    Nov 20, 2016
    Posts:
    400
    To draw a frame, unity combine all objects in to buckets and send them to GPU. By default, in URP, unity combine objects not only by material, but by distance too(and few other criteria). I.e. if you have a bunch of barrels far away, and bunch of barrels in front of you it's became 2 draw calls. If you use default URP nothing you can do with it. If you use URP fork or custom SPR - you can just exclude SortingCriteria.QuantizedFrontToBack from your sorting settings.
     
    mikeohc likes this.
  3. colin299

    colin299

    Joined:
    Sep 2, 2013
    Posts:
    181
    try clear material's old keyword in debug mode inspector
     
    night533 likes this.
  4. cassius

    cassius

    Joined:
    Aug 5, 2012
    Posts:
    125
    I have a feeling it's due to distance, but it seems inconsistent. There are objects over 100 units apart that are being batched, and then objects from the same prefabs within those 100 units that end up in a different batch. I just don't get it. :)

    How would one go about forking URP to make a custom one, is the source available somewhere? A custom SRP would be pretty unfamiliar territory for me.
     
  5. cassius

    cassius

    Joined:
    Aug 5, 2012
    Posts:
    125
    I'm not sure I follow. Do you mean bring up the inspector's debug mode? I thought the debug stuff presented is read-only.
     
  6. colin299

    colin299

    Joined:
    Sep 2, 2013
    Posts:
    181
    yes, try clear material's keyword slot in debug mode inspector
     
  7. cassius

    cassius

    Joined:
    Aug 5, 2012
    Posts:
    125
    I tried this out. Unfortunately, it seems to have had the opposite affect. The number of RenderLoopNewBatcher.Draw instances went from 89 to 97. Additionally, the visuals became somewhat "broken".

    I'm open to any other suggestions.