• RuntimesUnity
  • 使用了Multiple CanvasRenderers之后复制SkeletonGraphic(UI)对象会导致Batches(DrawCall)增加

我的角色身上有大量的装备必须使用多个图集,当使用多个图集时需要开启Multiple CanvasRenderers = true,如果Multiple CanvasRenderers是false的情况我复制SkeletonGraphic(UI)对象Batches(DrawCall)不会增加,但是当Multiple CanvasRenderers = true的时候复制SkeletonGraphic(UI)对象Batches就会增加,我场景中的角色很多,这样会有大量的Batches有没有办法让Batches不增加?我用的是URP Pipeline,现在用的shader是spine/skeletonGraphic,如果我开启outline = true,在Multiple CanvasRenderers = true的情况下会产生双倍的Batches。

Related Discussions
...

防止批次增加的最佳方法是在运行时将多个图集重新打包为单个图集。 请参阅[此处]的文档部分(https://zh.esotericsoftware.com/spine-unity#%E7%BB%84%E5%90%88%E7%9A%AE%E8%82%A4)。 这是您的选择吗?

否则,应用正常的 Unity 批处理规则。 它在很大程度上取决于网格边界以及具有相同两个或更多图集页面的多个“SkeletonGraphic”对象是否可以批量处理的位置。 如果它们在 XY 方向上不重叠并且位于相同的深度 (Z) 位置,它们仍将被批量处理,但并非总是如此。 一般来说,Unity 需要确保正确维护渲染顺序,因此一种安排可能会被批处理,而另一种则不能。

理论上可以批量为 AAA 和 BBB:

↓ 相机朝这个方向看

[A]   [A]   [A]
[B]   [B]   [B]

这不能批处理,因为渲染顺序是错误的,它必须像 A B A B A B 一样交替,因为它部分重叠:

↓ 相机朝这个方向看
    [A]
    [B]
  [A]
  [B]
[A]
[B]


The best way to prevent batches from increasing is repacking multiple atlases to a single one at runtime. Please see the documentation section here. Is this an option for you?

Otherwise, normal Unity batching rules apply. It heavily depends on the mesh bounds and on the position whether multiple SkeletonGraphic objects with the same two or more atlas pages can be batched or not. If they don't overlap in XY direction and are at the same depth (Z) location, they will still be batched, however not always. In general Unity needs to ensure that the render order is correctly maintained, so one arrangement might be batched while another can't be.

This can theoretically be batched as AAA and BBB:

↓ camera looking in this direction

[A]   [A]   [A]
[B]   [B]   [B]

This can't be batched since render order would be wrong, it must be alternating like A B A B A B since it's partially overlapping:

↓ camera looking in this direction
    [A]
    [B]
  [A]
  [B]
[A]
[B]