Search Unity

How to optimize drawcall for 2d renderer

Discussion in 'Universal Render Pipeline' started by xiao-xxl, Apr 8, 2022.

  1. xiao-xxl

    xiao-xxl

    Joined:
    Nov 16, 2018
    Posts:
    48
    Now each 2d light generates a new drawcall. This is a huge performance waste.

    Wondering what optimizations can be used on a 2d renderer.

    SRP Batcher?GPU instancing?Dynamic batcher?

    Do they work on 2d lights?
     
    Lo-renzo and aoisky0216 like this.
  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,511
    @rustum couldn't lights with compatible parameters be batched? For instance, I have 50 sprite lights on screen with only color and matrix differences.
     
  3. rustum

    rustum

    Unity Technologies

    Joined:
    Feb 14, 2015
    Posts:
    190
    Hi @xiao-xxl & @Lo-renzo! Thanks for the questions!

    We're always looking at improving performance of the 2D Renderer. It would be most helpful if you could tell us more about the result you are trying to achieve. Pictures and details are very useful too!
     
  4. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,511
    Here's an example: some terrain that's lit with quite a few lights that fade in/out over time.
    s1.png
    In the Frame Debugger, this produces a light texture like so (left) but many DrawMesh calls that are nearly identical (right).
    s2.png
    If these were normal sprites, not sprite lights, they would be batched. I know the 2D Renderer does all kinds of fancy stuff to batch light layers, but within a layer there's still individual DrawMesh calls.
     
  5. StayThirsty

    StayThirsty

    Joined:
    Jul 6, 2013
    Posts:
    42
    @rustum Any news on this?

    2D lights (no shadows) are not batching together when making a simple "ring" of the same 2D light. All lights are on the same layer too (URP 12.1.4):

    upload_2023-7-7_3-54-35.png |

    upload_2023-7-7_3-54-53.png
     
    Last edited: Jul 8, 2023