How to render multiple polylines with only one Polyline renderer component

Avatar
  • updated

Hi, I am writing just cause I couldn't find a question that covers what I am searching for.

I am drawing hundreds/thousands of polylines (imported from a dxf/dwg files) that represent the contour curves of a terrain. First I tried to do them with unity's LineRenderer - here it works fine, everything in 1 drawcall (I assume they are all somehow batched/ instanced) but the problem is I need these polylines to have a constant pixel size (similar to CAD applications)

I bought shapes cause it is truly unique at handling these geometries with instancing and in pixel scale. However it turned out, I couldn't have all my curves (using shapes polyline) and keep a low drawcall number (jumped from 30 to 500..), so I thought It might be possible to set multiple List<Vector3> polylines to my renderer, like SetPoints(List<List<Vector3>>), however, there is no such feature.. to the questions:

- would it be possible to do this overload, where I could draw several polylines (that are not connected) in the same Polyline renderer?

- will batching/ instancing ever be possible with Shapes.Polylines?

- alternatively, is there a way to use LineRenderer with the same approach that Shapes uses to keep a polyline always at, for example, 1px?

Thanks for your help and the amazing Library!

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
URP
Avatar
Freya Holmér creator

Being able to have breaks in polylines is something I've planned for the next major update for Shapes. Currently, you can work around it by using fully transparent points and/or collocational/degenerate/duplicate points between the visible parts of the polylines.

Instancing will only work for polylines that use the exact same mesh, which, most polylines don't. Right now, instancing won't work for the component polylines, since each component uses a unique mesh, but I think it works for immediate mode drawn polylines.

As for hacking line renderer to do pixel scaling, I'm not sure! I haven't tried