Search Unity

Question Standard Render Pipeline vs Universal Render Pipeline Batching confusion, 1 material = 2 drawcalls?

Discussion in 'General Graphics' started by Fressno, Dec 11, 2022.

  1. Fressno

    Fressno

    Joined:
    Mar 31, 2015
    Posts:
    185
    I have a confusing problem i hope you guys can help me with.
    Im trying to reduce drawcalls. I mean, really reduce it to a bare minimum.
    A model has only 1 material (base color, metallic, height, emission, normal map).

    If im using the URP and remove the PP volume and everything that requires a drawcall (skybox for instance),
    i get 5 batches as a starter base. 8 setpass calls. If i have the directional light selected.
    Now for each model (1.5k triss, 1 material) i have in the scene, it adds 2 batches if the material is opaque and doubles the triss to 3k. if i switch it over to transparent it gives me 1 batch and 1.5k for the model.

    is it suppose to do that? isnt it 1 material = 1 batch if i dont have any extra hooked up, like PP and stuff like that? and transparent? shouldnt transparent materials be more expensive?

    The Standard RP gave a smiliar result.
    everything turned off, opaque gives 2 batches, transparent 1 batch.
    but the starting batches is only 1, and 1 setpass call with absolutly nothing in the scene.

    At least the setpass calls work when i group the models in one empty GO and add static to it. If i increase the model count by duplicating one, it stays how many copies i make.
    But the draw calls increase with 2 for each 1 model i add. if im not using transparent, which is not what i want.

    how can i make unity only draw 1 batch for 1 material in opaque? in both URP and Standard RP.

    ask me anything and ill happily answer gaps in this explanation.
     
  2. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    766
    Hi, you can open the Frame Debugger to see how Unity renders a scene.

    For example, in the picture below, URP is executing a pass called "DepthNormalPrepass", which outputs scene normals & depth. (required by the SSAO effect)
    DepthPrepass.jpg

    On some platforms (usually OpenGL which Unity cannot copy depth), Unity will execute "DepthPrepass" to output scene depth if you/effects require a Depth Texture.

    It depends, but for most cases, they are more expensive.

    That's because GPU cannot skip meshes that are behind a (semi-)transparent mesh.

    This can lead to severe overdraw issues (GPU bottleneck) when there're many of them. (you can use URP Depth Priming / "mobile" GPU early-Z to reduce opaque overdraw costs)

    The reasons that sometimes a transparent material is performance cheaper can be:
    1. Transparent materials usually don't write depth to the camera's depth buffer (not Depth Texture, it's copied from camera depth at a time), so this makes them a bit less expensive compared to depth write enabled objects.
    2. Transparent materials won't execute any Prepass, so they can be less expensive and will be ignored by some post-processing effects.

    I think you can try these common batching techniques:
    • GPU Instancing (requires the same mesh & material, not automatically enabled)
    • Static Batching (idea is to combine meshes into a big one and use 1 material only)
    • SRP Batcher (only for SRPs, reduces the cost of each draw call)
     
  3. Fressno

    Fressno

    Joined:
    Mar 31, 2015
    Posts:
    185
    awesome! thanx! ill see what i can do with this. it helps more than it hurts anyway =)
     
    wwWwwwW1 likes this.