Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Linerenderer Inconsistent Widths

Discussion in 'Editor & General Support' started by amasinton, Feb 16, 2009.

  1. amasinton

    amasinton

    Joined:
    Aug 12, 2006
    Posts:
    137
    I'm using a line renderer to string together a series of spheres.

    When I add a sphere as a vertex, sometimes the line width starts very wide at one vertex and ends very narrow at the next. All of the spheres are on the same plane - there is no variation in 'depth'.

    I've attached a screenshot.

    Any ideas?

    Thanks!

    -- Anthony
     

    Attached Files:

  2. burnumd

    burnumd

    Joined:
    May 27, 2008
    Posts:
    367
    Can you provide some more information? Are you using an ortho or perspective camera? How are you setting the end points on your line renderer? I'm going to go ahead and guess that you've checked that the end widths on your line renderer are set the same. My guess at a glance might be that while your spheres are at the same depths, the line renderer end points aren't getting the correct values. If you're making a map and you haven't already done so, you might be able to sidestep the issue by switching to an orthographic camera. The one issue with that approach is that you appear to be doing an anaglyph stereoscopic effect, and using an ortho camera is going to negate that effect on anything that isn't already a 2D texture. For testing purposes, at least, doing so would let you know if it's a perspective issue or a line renderer width issue.
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,748
    That's just a side effect of the way LineRenderer works. You can usually get around or lessen the effect by inserting an extra vertex or two very close to the ones that look odd.
     
  4. amasinton

    amasinton

    Joined:
    Aug 12, 2006
    Posts:
    137
    Been unable to check the forums for a few days (work, work, work).

    Thanks for the replies.

    burnumd: I'm using a perspective camera. I have to. As you noticed, I'm working with anaglyphs, trying to do some cheap and cheerful stereo photogrammetry plotting, so, while the stereo effect works for the image, in ortho mode the depth of my spheres is not visible.

    The way I'm entering the points into the line renderer is by adding them one at a time to an array as the user creates the spheres. The linerenderer is constructed 'dynamically' in that the user can add points and move them around however they want. The coordinates of each point are set to the coordinates of each sphere in the array.

    I tried switching between ortho and perspective camera mode and the line width problem was the same in both.

    What I've done in the end is set the linewidth start and end to 0.01, which makes a very thin line where the differences in the displayed start and end widths are not that noticeable.

    StarManta: Since I'm exporting the vertices of the linerenderer to dxf format, putting secondary points very close to my main points introduces a lot of messy data.

    Again, thanks for the help, both.

    -- Anthony
     
  5. frumpel

    frumpel

    Joined:
    Nov 16, 2018
    Posts:
    2
    I know this is an ancient thread but I just ran into this as well using 2017.3.1f1. It seems that this is a "feature" of the way LineRenderer draws lines. Apparently it will not simply "pivot" or "double back" at vertices the way one might expect. The following picture shows what happens if the line doubles back. Notice the odd corner on the right:

    polyline.png

    This was generated as per the attached image. Setting the CornerVertices to 0 gives overly sharp and narrow results. Setting them to 1or more yields odd fat corners. Similarly setting EndCapVertices to 0 gives odd sharp endings while setting them to 1 or more gets increasingly rounded outcomes.

    line-renderer.png

    Experimenting with this a bit more also suggests that an increasing amount of erros gets added as the line gets longer, likely some sort of side-effect of whatever triangulation the LineRenderer does:

    poly-errors.png
    My guess would be that to do better than "draw thin enough that it won't be noticeable" the next best solution would be to composite an object from straight line segments.
     
    MilenaRocha likes this.
  6. frumpel

    frumpel

    Joined:
    Nov 16, 2018
    Posts:
    2
  7. ex-nihilio

    ex-nihilio

    Joined:
    Jan 23, 2015
    Posts:
    12
    Put at least three same points for each line points
    and do not use simplfy function.
     
    samana1407 and Error_0x89A like this.
  8. LeHombreDeZbragl

    LeHombreDeZbragl

    Joined:
    Jan 31, 2021
    Posts:
    3
    I was making game where u click on player, drag and a line renderer will appear. It had inconsistent width and i solved it by going LineRenderer > Alignment > TransformZ. Don't know why is that but it's woking for me. And i'ts little pixely.
     
    Last edited: Feb 10, 2021
    spider853 and Demulc like this.
  9. nixxy10

    nixxy10

    Joined:
    Jan 18, 2017
    Posts:
    1
    Increase the Corner Vertices on the line renderer in its inspector. Solved it for me.