2D Sprite Shape SRP Batching Support

The sprite shape render node doesn’t currently support SRP batching even if the assigned shader is compatible. The result is that each edge and fill is drawn separately, drowning performance with draw calls on scenes with many sprite shapes.

Is compatibility planned? Is there a workaround in the near term, such as a way to bake static sprite shapes into a mesh for use with a renderer that is supported?

Thanks for posting. We will consider adding support for this in a future version.

I second this, there should be some way to reduce the drawcalls on Sprite Shape. I also wonder if Sprite Shape is regenerating the mesh every frame? Or just when its shape has been changed? I am creating the Sprite Shapes in runtime ( only once during loading time ) and while it works, I have suspicion that performance hit would be heavy. I also don’t know what this Bake() supposed to do. Is it meant only be used in Editor mode and cache geometry and save it in the scene?

I third this. We’re ready to really utilize Sprite Shape in our game but we are developing for Switch and cannot afford the high amount of Draw Calls that using it will cost us!

If we don’t need to modify the shape per every frame update, we should be able to batch the similar sprite shapes that are using the same setup regardless if they are created during runtime or editor time. Ofcourse I can understand the sorting can interfere with the drawcalls but other than that they should be treated as the other sprites that are using the same material and the same atlas.

Having said that, (I could be wrong but ) I am not even sure if SRP batching even works with 2DRenderer at the moment. I think … it isn’t at all. So maybe when 2DRenderer gets SRP batching it could happen?

To add a question to the above, I want to know what happens to sprite shape rendering process in runtime. Does it regenerate its drawing mesh every time per frame? Or only when it is needed because their property changed such as curve points. And does it repect other usual culling such as frustrum culling?

It doesn’t work? That may explain why Frame Debugger is giving me nonsense…

As far as I know SRP batching does not work with current 2DRenderer. Which is sad, but I am so eager to find out if it ever will, and if so it can increase performance. Right now, it only seems to do the “dynamic” batching which I think it is similar to old cpu batching used to work for the builtin pipeline.

  1. Drawing Mesh is not generated every Frame. SpriteShape Geometry is only generated when there is a change in Inputs (Spline, SpriteShape Parameters etc…) You can also save the generated geometry to be used in Runtime instead of being generated.
  2. Yes, SpriteShape Renderer as all other renderers are culled if not visible.
  1. SRP Batching is not compatible with 2D Renderer.
  2. Please use Atlas or SpriteSheets for sprites used in SpriteShape Profile, so that each SpriteShape is rendered in 2 draw calls regardless of the complexity of the SpriteShape or Vertex count. While we explore ideas to improve it further, please do note that Dynamic Batching has its limitations like 300 vertices etc… (https://docs.unity3d.com/Manual/DrawCallBatching.html)

any updates to the sprite shape batching issues?

2 Likes

any updates to the SRP Batching with 2D Renderer?

I would also like to know if the SRP Batcher is compatible with the 2D Renderer.

In 2023.1 alpha the 2D Renderer was made compatible with SRP Batching.

Whether this applies specifically to Sprite Shape I haven’t yet tested, but it does work for Sprite Renderers at least.

Yes, In Unity 2023.1.0a18 we have added SRP Batching support for SpriteRenderer, SpriteShapeRenderer and TilemapRenderer. Thanks.

2 Likes

Will this be backported to Unity 2022.2 or 2022.3?

Unity Features are never backported, only bug fixes.