0
\$\begingroup\$

I have a database of country, state, and even county level borders and I'm stuck in a situation where I either have 1000+ linerenderers in the scene OR I have a single line that connects every border across the globe, neither of which is desirable.

Part of the issue is how the data comes in, in tiny chunks of 4-5 points that may be in the us then the next set of points will be in china. It seems there's no "simple" way to do this so I'm starting to think I'll need to do all my draws with a shader OR draw lines to a material.

Is there any way to use a single LineRenderer that has sizable gaps in the line?

** EDIT **

Playing around with some things and I've condensed all the line draw to per map tile and performance is already WAY up. The problem now is that I have lines stretching across the map in multiple places since I haven't found a good way to put an "invisible" line section in the middle of a line renderer series

LineRenderer border bug for wester usa

\$\endgroup\$
2
  • \$\begingroup\$ What actual goal are you trying to achieve? Country borders are not really changing that often, if you want to highlight states, counties or countries within, it would as well depend how you render them \$\endgroup\$
    – Zibelas
    Feb 7, 2022 at 16:13
  • \$\begingroup\$ @Zibelas Right now I'm suffering from 1000+ line renderers with their associated game objects which is starting to effect performance. A single visible border (line) may have 100+ breaks in it which is where the extra line renderers come from and writing functionality to optimize the line data will take too long so I'm looking for shortcuts. Theoretically a single line renderer that can do "lineto" draws (which it already does) as well as "moveto" draws in the same gameobject seems efficient enough for my purposes. \$\endgroup\$
    – Jacksonkr
    Feb 7, 2022 at 17:46

1 Answer 1

1
\$\begingroup\$

There's "the right way" to solve this issue and then there's the sneaky way. I took the sneaky way:

For the "move to" line operations I'm doing the following:

  • add a point to the linerenderer that goes BEHIND my material (so it's not visible)
  • while behind the material I then draw a line to the where the new drawing location will be
  • I draw an third line back to the surface of the material
  • continue "line to" instructions
\$\endgroup\$
3
  • 2
    \$\begingroup\$ So, you're "sewing" the line renderer and showing only what is needed. I like the sneaky part, but be aware of performance issues: surfaces are occluding the renderer but those lines are still being rendered. \$\endgroup\$
    – liggiorgio
    Feb 14, 2022 at 16:41
  • \$\begingroup\$ @liggiorgio you are 110% correct. Fortunately the performance ding is unnoticeable, I'm guessing because LineRenderer seems to leverage shaders almost entirely. \$\endgroup\$
    – Jacksonkr
    Feb 14, 2022 at 18:51
  • \$\begingroup\$ What would be "the right way"? \$\endgroup\$
    – dankal444
    Dec 29, 2022 at 10:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .