Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

SRP Batcher and number of materials

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

  1. lama89625

    lama89625

    Joined:
    Feb 14, 2019
    Posts:
    13
    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:
    13
    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.
     
unityunity