Search Unity

Question SRP Batcher and GPU Instancing

Discussion in 'Shaders' started by Alixar, May 22, 2023.

  1. Alixar

    Alixar

    Joined:
    Mar 13, 2019
    Posts:
    50
    Hello all,

    I have some doubts about the SRP Batcher: if I'm working with lots of identical meshes (foliage) that differ in certain properties (color and scale in my case), is it realistic to expect the SRP Batcher in URP to provide a more or less similar performance gain as I would get with regular instancing?

    And also: is ti possible to use instancing with a particular shader/material and batching with others, or the 2 are mutually exclusive?

    Thank you!
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    SRP Batcher is decently faster for smaller numbers of identical objects, slightly slower for a large number of identical objects. But it's shockingly close. Unless you're trying to push multiple tens of thousands of instances, SRP batcher is more than sufficient.

    And yes, you can do both instancing and the SRP Batcher, but you have to do the instanced draws manually via script as the automatic instancing won't ever be used when the SRP Batcher is enabled. At least as far as I know. It might be possible to have a GPU instanced compatible shader that isn't SRP Batcher compatible, but I'm not entirely sure how.
     
  3. Alixar

    Alixar

    Joined:
    Mar 13, 2019
    Posts:
    50
    Thank you @bgolus I am running a few experiments to render grass blades and leaves, so I am indeed expecting a few tens of thousands objects in view, but before getting there I wanted to understand which approach would be best for my case, whether it was SRP or attempting instancing.

    Also thank you very much for clarifying that I can use both in case of need.
     
  4. mahito2932

    mahito2932

    Joined:
    Nov 15, 2020
    Posts:
    115
    Can you give some example please?
    When I enable SRP batcher I can't no more use GPU instance at all. It doesn't save batches. When I disable SRP it start working as it should be.