Search Unity

Issue with the SRP Batcher

Discussion in 'Universal Render Pipeline' started by unity_Mmj6J1f2NPTEXA, Jun 15, 2020.

  1. unity_Mmj6J1f2NPTEXA

    unity_Mmj6J1f2NPTEXA

    Joined:
    Jul 29, 2019
    Posts:
    1
    Hello Everyone,
    I recently shifted our project to URP 7.4.1 and thought about giving SRP batcher a try. Went through the docs which state that a batch in SRP is broken when we change the shader variant. I did a test run on my scene and found out that the batcher might be working a little weird. Not sure if I understood correctly about the SRP batching or not but from what I could gather the situation below should not have happened.

    Image 1 : First SRP batch as you can see it is SimpleLit shader.

    upload_2020-6-15_16-16-54.png

    Image 2 : Second SRP batch, a different shader variant i.e Lit.

    upload_2020-6-15_16-18-34.png

    Image 3 : Third SRP batch, the same shader as Image 1 i.e SimpleLit and also all the textures and other properties are the same.

    upload_2020-6-15_16-19-3.png

    Image 4 : This is the same shader from the 2nd image with all the properties same.

    upload_2020-6-15_16-24-11.png

    My question is why did URP create a separate batch for the two similar shader variants when it should clearly be combined with the 1st batch and 2nd batch altogether and the Draw calls should only be 2. Is there any limit on the batch vertex count or did URP create the batches based on distance from camera and not from the fact that they have the same shader variants applied. Or am I completely wrong in understanding this simple concept.
    Please let me know if the above points are confusing, I can clarify on the same.
    Also if there is a way to change the distance sorting of batches if that is occuring, how should I proceed with this.

    Thanks.


    Edit 1 : Just after posting this reply I thought about changing the priority slider in the material to see if distance sorting was causing trouble through this and it seems to have created 2 batches instead of 5 which seems to have solved the issue. I will run some more tests and see if this completely resolves the issue.

    Edit 2 : The previous edit resolves the issue completely.
     

    Attached Files:

    Last edited: Jun 15, 2020