Can I draw multiple line segments in one drawcall?

Avatar
  • updated
  • Answered

There are a lot of points in the scene, and I want to draw a line between points that are close to each other. I wonder if it is possible to draw all the line segments at once from the efficiency point of view?

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Avatar
Freya Holmér
  • Answered

Shapes uses GPU instancing, so if you're using components, the same shapes should draw in the same draw call the same way any other GPU instanced mesh will draw.

If you're using Immediate mode drawing, it will batch consecutive calls to the same function into the same draw call.

in other words, this would be 4 draw calls:

Draw.Line(...)

Draw.Disc(...)

Draw.Line(...)

Draw.Disc(...)

this would be 2 draw calls:
Draw.Line(...)

Draw.Line(...)

Draw.Disc(...)

Draw.Disc(...)