How to render 6,000,000 Lines without performance issues

Avatar
  • updated
  • Answered

Hello! I'm using Unity to create a 3D visualization tool.
I'm trying to use your assets because the ability to style the lines is poor in Unity.
Previously, we succeeded in rendering 6,000,000 lines (500,000 cubes) without performance issues by using MeshTopology.Lines.
However, when using Immediate-Mode Drawing of this asset, frame drops occur even when there are only 120,000 lines.
Is there any way to draw so many lines on this asset? If that's not possible, how many line segments can you roughly draw on a typical desktop specification?

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

MeshTopology.Lines is one of the most low level basic rendering methods, in this case setting up a cached vertex buffer to render later, which is the fastest way of doing this.

immediate mode is designed for dynamic data, so running 6,000,000 lines dynamically per frame will just be impossible no matter how you do it, and this is hitting even hardware/CPU limitations, especially in C#

it *might* be possible in the coming update to speed this up a little bit using the new polylines, as long as it's not dynamic, but I can't promise it would help in this case I'm afraid!

as for the limit - it depends really on the hardware, I don't know! you'd have to test on your target device. and be sure to test in builds rather than in editor, since build performance is much better than editor performance :)