Drawing a line with greater detail

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By stubbsy345
:warning: Old Version Published before Godot 3 was released.

I understand how to draw a line using the godot draw_line function. However, what I am wondering is is there a why of making that line more details. For example by adding depth by shading the sides slightly, as if to make it look like a tube. A good example of the detail I would like to replicate are the lines you would use to connect nodes in the node editor in blender?

Thanks in advance!

there is similar functionality, but it will be with 3.0
Polyline by Zylann · Pull Request #7352 · godotengine/godot · GitHub

volzhs | 2017-05-18 02:33

You can use shaders over lines drawn by _draw, but I have no idea how to get things like the UV or position (modifying the CanvasItem rect, maybe?).

May be easier to simulate a line with a polygon.

eons | 2017-05-18 16:09

:bust_in_silhouette: Reply From: Rasmus

An easy solution that works really well (i use it myself) is to draw two lines on top of each other.

The trick is to set the opacity on both lines at ½ the final opacity, fx 0,5 if you want a solid line, and making one line a bit bigger that the other.

draw_line(from_pos, to_pos, Color8(255, 255, 255, 255/2), 4)
draw_line(from_pos, to_pos, Color8(255, 255, 255, 255/2), 3)

Before and after example from my game (Code above is just an example, not exactly what i use):

Before
enter image description here

After
enter image description here

I am not 100% sure this technique can work for your exact needs but i thought i would throw it out there anyway :wink: