Line Renderer sharp turns issue

I’m having an issue with the way Line Renderer deals with “sharp” turns. It seems that line renderer really tries to over the line overlapping with itself, to the point that it has really ugly behavior around places where the line makes a sharp bend. For example, here you can see the beam making a sharp turn:

7522388--928178--upload_2021-9-25_14-34-53.png

If I move the camera up just a little, it dramatically changes the rendering, swapping the positions of the two segments of the line:

7522388--928181--upload_2021-9-25_14-35-9.png

It always tries to keep some distance between the lines, rather than letting them overlap at all. I’m not sure why it tries so hard to avoid overlap, but I would prefer it allow the overlap, in this case. I was wondering if anyone know of a way to avoid this behavior.

Setting Corner Vertices to 0 is the only thing I’ve seen that has any impact on this. However, using 0 for corner vertices also has the consequence that the rest of the line doesn’t render properly at all anymore. It essentially loses its billboard behavior, and becomes a flat line when views at various angles. The sharp point of the line also extends quite a bit beyond the coordinates of the Position being passed to the Line Renderer:

7522388--928184--upload_2021-9-25_14-35-49.png

Any other ideas? This is in HDRP, if it matters.

1 Like

LineRenderer has always been kinda half-written. Until about four years ago it was barely even usable, and then they did a burst of work improving it (I think in Unity2017?), but it still falls far short of a general-purpose vector line drawing utility.

You can work around some of the limitations by inserting extra points to “round out” a corner and help LineRenderer miter it properly, but it starts to get nasty after a while.

Once you reach its limitations I think the only solution is to reach for something more-full-featured, such as Vectrosity:

Thanks for the suggestion. I’d already tried the approach of adding an extra point, but my results were substantially worse than the original issue I was seeing. I still find it particularly strange that Unity’s approach goes out of its way to avoid overlap. I guess they’re going for a representation of a physical object, like a wire, where overlap wouldn’t be allowed. I’ll check out the asset store for a solution. Thanks again.

It might be some attempt at inner corner mitering gone wrong… make sure the double points are separated by “enough” distance, whatever that might need to be.