Search Unity

SRP Batcher and number of materials

Discussion in 'General Graphics' started by lama89625, Oct 11, 2019.

  1. lama89625

    lama89625

    Joined:
    Feb 14, 2019
    Posts:
    14
    Hi everyone! Looking for help from anyone who’s had more experience with the new batcher.

    From this blog post
    https://blogs.unity3d.com/2019/02/28/srp-batcher-speed-up-your-rendering/
    it would seem that the number of materials shouldn’t affect the render time at all as long as the materials’ parameters aren’t changing constantly.

    I did a test (Android, gles3.1) where I had a couple hundred objects on screen (1 shader drawn in just 2 srp batches) that shared several dozens of materials (textures and float properties are different per material)
    When I run
    r.material = new Material(r.sharedMaterial)
    for each renderer the number of batches and everything else in the Frame Debugger stays the same but the CPU render time almost doubles.

    Has anyone noticed the correlation between the number of materials and performance?
     
    Last edited: Oct 11, 2019
  2. lama89625

    lama89625

    Joined:
    Feb 14, 2019
    Posts:
    14
    So from what I've seen from my tests the number of materials does matter so it's better to try to keep it to a minimum. Whereas how different those materials are (whether they reference the same textures or not etc.) doesn't actually matter that much.

    When you go from one shared material to every object having their own material it's about half of the original performance. And looks like it's a linear dependance of the number of materials.

    In any case the performance is much better with the new batcher in the 'one shader - many materials' scenario.
     
    JackTruong likes this.
  3. NanushTol

    NanushTol

    Joined:
    Jan 9, 2018
    Posts:
    131
    trying to decide on some optimizations techniques, came across this just now, are you running this line on update? or at start/enable?
    r.material = new Material(r.sharedMaterial)