Polylines where consecutive points have the same position don't render properly

Avatar
  • updated
  • Answered

Hello!

I'm making a laser game (woohoo!) and I'm trying to use Polyline for the laser segments. It's great because I can have joints in the laser path that make the line much nicer! However, I often want to change a properly of the line immediately. For example, change the alpha-channel of the colour to make it look like there's "less energy" in the beam once it goes through certain optical elements. I've done this in the past by having a "double-point" in which the colour changes. Check the following settings (especially the points B and C):

Image 104

This however gets the Polyline to render oddly. I understand this is due to NANs cropping in when calculating the direction between point B and point C, which is ill-defined as they're at the same position.

I thought about creating different Polylines to create the sharp change, but then I will not get nice joints!

Do you have a suggestion on how to handle this?

Thanks a bunch!

ALE

Reporting a bug? please specify Unity version:
2019.4.10f1
Reporting a bug? please specify Shapes version:
2.3.0
Reporting a bug? please specify Render Pipeline:
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Answered

I might look into solving this in the future, but I'm generally avoiding it as there's a performance overhead in solving the special case where the points are in the same location, and that would likely go to the CPU, since the GPU has no idea about points further away than its neighbors (which is required for the directions to be calculated properly)

a workaround for now would be to put a tiny offset in the same direction of the line, like 0.001 or something, that would make it indistinguishable from having a point in the same location

Avatar
Freya Holmér creator
  • Answer
  • Answered

I might look into solving this in the future, but I'm generally avoiding it as there's a performance overhead in solving the special case where the points are in the same location, and that would likely go to the CPU, since the GPU has no idea about points further away than its neighbors (which is required for the directions to be calculated properly)

a workaround for now would be to put a tiny offset in the same direction of the line, like 0.001 or something, that would make it indistinguishable from having a point in the same location

Avatar
Ale Cámara

Makes sense. Thanks for the prompt reply! :)