Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Batching and Sorting Groups

Discussion in 'Universal Render Pipeline' started by KMacro, Sep 17, 2019.

  1. KMacro

    KMacro

    Joined:
    Jan 7, 2019
    Posts:
    48
    I have a prefab that contains a root object and two children with Sprite Renderers (a palm tree with its trunk in the first child's sprite renderer and its leaves in the second child's sprite renderer to make it easier to visualize).
    Three of these palm trees are children of another object "BackgroundElements".

    I would expect the drawing of the trunk sprites to be batched and the drawing of the leaf sprites to be batched, and this is the behavior I see in the Frame Debugger. However, if I add a Sorting Group component to BackgroundElements, this batching breaks and I see the following draw order: Trunk 1 -> Leaves 1 -> Trunk 2 -> Leaves 2 -> Trunk 3 -> Leaves 3

    Is this just an unfortunate side effect of using the Sorting Group component, or is there a way for me to get Unity to batch the draw calls in the same way I see without the Sorting Group component?

    All of the Sprite Renderers are on the default layer with sorting order 0. I am using Unity 2019.1.10f and LWRP 5.7.2.
     
  2. modernator24

    modernator24

    Joined:
    Apr 7, 2017
    Posts:
    186
    I'm also interested this in. Is there any news about this? After using the sorting group, my batching also broken, and draw call increased a lot.
     
  3. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    349
    Is it even possible to batch sprite rendering if they use an arbitrary sort order among themselves? There is an old thread explaining batching.
     
    Last edited: Sep 2, 2020