General performance tips for many Shapes

Avatar
  • updated

Hello,

I am trying to draw lines created and imported from a CAD software.

There are multiple 1000 of Lines, Arcs, Polylines, Splines and Text elements.

Currently I'm creating one GameObject for each (except Text) element. No immediate drawing. Build-in RenderPipeline.

Many lines have different positions but not so many different characteristics (color, thickness, style etc). Perhaps 20 different styles in total

On an example scene I'm using for tests has > 65000  lines, > 20000 arcs, > 500 splines.
Batches: 5400, Saved by batching ~75000

Anything I can try to improve this? Running quite low on high end PC

Reporting a bug? please specify Unity version:
2022.1.24f
Reporting a bug? please specify Shapes version:
4.3.1
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Avatar
Freya Holmér creator

that's a pretty significant amount of stuff to have as separate objects. once you hit these amounts, a lot of it is about merging multiple things into one mesh, which Shapes doesn't currently have support for

I'd double check the frame debugger - it usually says why batches are broken and why draw calls can't be merged, it might contain more info. (although it's possible it's just because of the sheer quantity)

Shapes also relies on GPU instancing, so make sure that's working correctly in your setup

There is a long term update I've been working on that would at least allow you to combine multiple lines/polylines into a single render, which would help a lot in this case, but it's not quire ready yet!

Avatar
christian petry

Alright, I'll check why the batches are braking. Could this be some kind of ordering issue when the lines are created? (wild guess).

Oh yes your update could really help. I often have the case of multiple lines being some kind of group but I can't use polylines as they are not necessarily connected or ordered in a "path".
Could it help to manually try to stitch groups together where this is possible?
Otherwise I'll wait for your update.

Avatar
Freya Holmér creator
Quote from christian petry

Alright, I'll check why the batches are braking. Could this be some kind of ordering issue when the lines are created? (wild guess).

Oh yes your update could really help. I often have the case of multiple lines being some kind of group but I can't use polylines as they are not necessarily connected or ordered in a "path".
Could it help to manually try to stitch groups together where this is possible?
Otherwise I'll wait for your update.

it might help, but mind that polylines can't make use of GPU instancing, so they'll be their own draw call per polyline