Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Does Material.SetBuffer() brakes SRP batching?

Discussion in 'Universal Render Pipeline' started by kulesz, Dec 5, 2022.

  1. kulesz

    kulesz

    Joined:
    Jul 1, 2012
    Posts:
    136
    Hi,

    I tried to use Material.SetBuffer() to pass some arguments to the shader, but it appears that it brakes SRP batching somehow. I checked Frame Debbuger and found out that all my meshes are not batched because "This material has custom buffer override".
    If I remove SetBuffer call everything is batched fine.

    Is there any way to pass custom buffer to material without breaking batching?
    As I cannot use Material Property Block and pass values directly to the material (because it'll create new instances) - is there any other option?

    upload_2022-12-5_20-6-52.png
     
  2. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,579
    By using a global buffer that is accessed by all instances of that material.
     
  3. kulesz

    kulesz

    Joined:
    Jul 1, 2012
    Posts:
    136
    Unfortunately this buffer contents must be slightly different for each object instance.