I been trying for a while to draw smooth lines in Unity but with Line Renderer I obtained only jagged lines with the corners not rounded, in particular when the angle of curvature is really small . I incresed the value of antialiasing in quality settings and tried different materials but nothing changed. I also tried to instantiate a sphere every time the mouse move but it creates some gaps between the various spheres, in particular when the mouse go fast. I know there is a plugin called Vectrosity for this but there is a way to achieve this whitout it?
相关问题
- Unity - Get Random Color at Spawning
- Unity3D WebGL Headless not rendering
- Unity3D loading resources after build
- Load Image from Stream/StreamReader to Image OR Ra
- Unity3D - Build Failed because of “[Unity] ERROR:
相关文章
- Programmatically setting and saving the icon assoc
- Omnisharp in VS Code produces a lot of warnings ab
- Call non-static methods on custom Unity Android Pl
- Difference between SuspendLayout and BeginUpdate
- How can a game created in Unity can run on an Andr
- How to add Persistent Listener to Button.onClick e
- Placing an object in front of the camera
- Dynamic text printed on the desktop using Delphi?
I had this issue with Unity 2017.2. I tried changing my AA settings to max to get rid of line render jaggies. Didn't work and it was frustrating.
My solution was resolving the problem that MSAA was turned off on the camera because rendering was deferred. The camera has a setting for "use graphics settings" which should have never messed up in the first place, but I'm a beginner - I don't know much. I changed the setting to "forward" and my jaggies disappeared into the mist.
If I was more industrious, I would post before and after images.
Thanks to @Iggy 's inspiration and tutorials on catlikecoding.com (where the spline code I'm using comes from), I created a component that will create a mesh based on a spline given a width and sample frequency. Higher sample frequency = smoother curve of course.
I finally got this working thanks to @Iggy's excellent answer.
Create a new Image on your canvas, delete the Image script and replace it with UICubicBezier.
To give:
You can get some good results by generating a mesh from a set of points.
The algorithm for it is as follows:
v = (p2 - p1)
(marked in blue). Then rotate that vector by 90 degreesnormal = v.y, -v.x
marked in red.[i, w/2 + i, w/2 + i + 1]
wherei
is the current index, andw
is the total number of vertices.[i, w/2 * i + 1, i + 1]
This was a problem in Unity 5.4 and below. This problem has been fixed in Unity 5.5 and above after
LineRenderer
was completely re-designed.All you have to do is update to Unity 5.5 or version above and this problem should go away.
There is a new variable called
LineRenderer.numCornerVertices
. You can use that to set how smooth you want the line to be. The value of 5 seems fine for this.There is also another new variable called
LineRenderer.numCapVertices
that can be used to set how smooth the end of the line should be.This is a screenshot that demonstrate between 5.4 and 5.5 the changes: