Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

line_draw always draws with width=1 #8289

Closed
nunodonato opened this issue Apr 6, 2017 · 26 comments
Closed

line_draw always draws with width=1 #8289

nunodonato opened this issue Apr 6, 2017 · 26 comments

Comments

@nunodonato
Copy link
Contributor

Operating system or device - Godot version: Godot 3(master), Linux

Issue description:
Using any width value in draw_line seems to be useless, the drawn line is always 1px(?) in width.

@akien-mga
Copy link
Member

From IRC logs:

[17:33] <reduz_> nunod, in 3.0? not sure what to do about it, opengl 3.x does not support it
[17:33] <reduz_> nunod, as well as antialiasing, it's not supported either
[17:34] <reduz_> nunod, there probably should be a way around this, but i have no idea how to solve it
[17:34] <reduz_> for line width, a triangle could be used, which is not too bad
[17:34] <reduz_> well, two triangles
[17:34] <reduz_> but for antialiasing, no clue
[17:34] <nunod> reduz_, antialiasing seems to work fine
[17:34] <nunod> only the width is ignored
[17:35] <reduz_> i know, i mean antialiased thick lines
[17:39] <reduz_> nunod, it could be done with a shader without that much difficulty i guess, will have to see how to fix this eventually
[17:40] <reduz_> it must be fixable somehow
[17:40] <reduz_> i can think of ways to fix it, it's just not simple
[17:41] <Akien> reduz_: https://mattdesl.svbtle.com/drawing-lines-is-hard
[17:42] <Akien> Looks useful

@Zylann
Copy link
Contributor

Zylann commented Apr 6, 2017

In Godot master it's possible to draw polygon-based thick lines with Line2D ;)

@nunodonato
Copy link
Contributor Author

nunodonato commented Apr 6, 2017

@Zylann I tried it, but can't get anything to show on the screen, thought it was broken. Any examples available?

@Zylann
Copy link
Contributor

Zylann commented Apr 6, 2017

2D shapes themselves aren't broken, but this is: #7840 (comment)

Currently Line2D is just a Node2D with a list of points and some rendering options.
An example while it was WIP: https://www.youtube.com/watch?v=ikrJy9y7PEs

@nunodonato
Copy link
Contributor Author

@Zylann so... it doesnt work at the moment, right? :)

@Zylann
Copy link
Contributor

Zylann commented Apr 6, 2017

It works but you can't see it (in the issue I linked you can see the wireframe is correct), so... for the end user it doesn't works indeed, until that bug is fixed^^

@nunodonato
Copy link
Contributor Author

so I guess its safe to close this, since the problem is basically in #7840 , right?

@Zylann
Copy link
Contributor

Zylann commented Aug 27, 2017

I found SpatialMaterial has an option for line width, which I needed to make some debug lines more visible, but it has no effect. Should it be removed or are there plans to implement general purpose line rendering in both 2D and 3D?

@JohnMeadow1
Copy link

I consider this an regression since Godot 2.1.5 where I had this:
obraz
As for Godot 3.1. alpha 2 I have this :
obraz

Parameter Line Width for GeometryInstance does nothing, and is drawn as 1.

@akien-mga
Copy link
Member

If not done already, it could probably be reimplemented in the GLES2 backend. According to @reduz in #8289 (comment) the usual method is not supported in GLES3, so it needs a different implementation (or it will be fixed only when properly implemented in the Vulkan backend).

@JohnMeadow1
Copy link

I have tested GLES2 on Godot 3.1 alpha 2, and it is the same.
So maybe we should drop or disable Line Width property in GeometryInstance for now?
It can be quite confusing, at current state.

@akien-mga akien-mga added this to the 3.1 milestone Dec 5, 2018
@akien-mga akien-mga added bug and removed enhancement labels Dec 5, 2018
@JohnMeadow1
Copy link

JohnMeadow1 commented Dec 7, 2018

I have researched this a bit, and apparently this is not a bug.
According to some standards (sorry no source) rendering API should support rendering a line with at least 1px wide.
What I managed to dig up is that modern Opengl, and DirectX support line_width=1 and that is all.
This is probably because drawing a line as a geometry is usually used only for debuging (e.g. ray tracing) and wireframe rendering. For game purposes you will most of the time use textured quads, So this is why they might have dropped it.

Regarding Line Width property in GeometryInstance. If we want to render lines that are thicker, we need to write our own method for doing so. Line Width property is just not supported.
Unless I'm completely wrong, we might just need to drop Line Width property altogether, and think about Lines3D node.

As mentioned before drawing-lines-is-hard.

@blakeearth
Copy link

Draw_line's width parameter works as expected on my Windows machine running 3.0.6 Stable.

@Skaruts
Copy link

Skaruts commented Jul 24, 2019

I'm having this problem in 3D (SpatialMaterial) in Godot 3.1.1, in both GLES2 and 3.

Should there be a separate issue for 3D?

@Calinou
Copy link
Member

Calinou commented Jul 24, 2019

@Skaruts It seems the 3D issue has been mentioned above in this thread, no need to create a new issue.

@Skaruts
Copy link

Skaruts commented Jul 25, 2019

@Calinou, indeed. I was just wondering.

Although, I'm also wondering how the editor's 3D gizmos are drawn. Because they have thick lines. Could you point me to the place in Godot's source where this happens? I've no clue where to find it, but I wonder if I might find a workaround there.

@Calinou
Copy link
Member

Calinou commented Jul 25, 2019

@Skaruts It's in editor/spatial_editor_gizmos.cpp:

void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard) {

3D gizmos are drawn using procedural meshes generated using ArrayMesh. The add_lines() method above uses PRIMITIVE_LINES, which means it will still rely on OpenGL line drawing. However, some other kinds of "lines" (like the manipulator gizmo) use cubes or cylinders to emulate thick lines.

@Skaruts
Copy link

Skaruts commented Jul 25, 2019

@Calinou interesting... I always thought the manipulators would be made with ImmediateGeometry.

Anyway, thanks a lot for pointing me to it.

@Calinou Calinou modified the milestones: 3.2, 4.0 Sep 4, 2019
@bluenote10
Copy link
Contributor

bluenote10 commented Dec 13, 2019

For me (v3.1.2 stable, Linux) the width seems to be working, but it is the antialiased=true which doesn't seem to have any effect:

draw_line(Vector2(0, 0), Vector2(100, 200), Color(255, 0, 0), 3.0, true)

image

Is this expected / tracked by this or another issue?

@ScribbleFen
Copy link

For me (v3.1.2 stable, Linux) the width seems to be working, but it is the antialiased=true which doesn't seem to have any effect:

draw_line(Vector2(0, 0), Vector2(100, 200), Color(255, 0, 0), 3.0, true)

image

Is this expected / tracked by this or another issue?

I'm on v3.2 stable, Linux, having the same issue with anti-aliasing

@Calinou
Copy link
Member

Calinou commented Feb 23, 2020

@bluenote10 Color(255, 0, 0) will create an extremely overbright red color (255 times brighter than a non-overbright red). This is why you can't see the antialiasing effect at all, even though it's technically there. You want to use Color(1, 0, 0) or Color8(255, 0, 0) instead 😉

@KoBeWi
Copy link
Member

KoBeWi commented Dec 24, 2020

Can anyone still reproduce this bug in Godot 3.2.3 or any later release?

If yes, please ensure that an up-to-date Minimal Reproduction Project (MRP) is included in this report (a MRP is a zipped Godot project with the minimal elements necessary to reliably trigger the bug). You can upload ZIP files in an issue comment with a drag and drop.

@Skaruts
Copy link

Skaruts commented Jan 10, 2021

@KoBeWi it's not working for me in 3D, netiher in GLES2 nor GLES3. Lines are all 1 width. However, GLES3 doesn't work well anyway in my old Radeon HD 4870, and I don't know if it's supposed to work in GLES2 to begin with.

I suppose I can try to find time to make an MRP, if this is supposed to work in GLES2. I won't fiddle with GLES3, as it stalls a lot on my end.

@Calinou
Copy link
Member

Calinou commented Jan 10, 2021

However, GLES3 doesn't work well anyway in my old Radeon HD 4870, and I don't know if it's supposed to work in GLES2 to begin with.

GLES2 should work on old GPUs, but GLES3 isn't expected to work correctly indeed.

That said, unlike NVIDIA, AMD didn't implement line widths above 1 in their OpenGL line drawing code. This is why #43828 in 4.0 solves this problem entirely by not relying on OpenGL line drawing in the first place.

@Skaruts
Copy link

Skaruts commented Jan 10, 2021

GLES2 should work on old GPUs, but GLES3 isn't expected to work correctly indeed.

I meant the line widths, though. But I guess you answered my question, and it's not supposed to work at all in my gfx card, at least in 3.x. (I'll be switching to an NVIDIA soon anyway.)

Although it's odd then, that I had line widths in Godot 2.

@YuriSizov
Copy link
Contributor

I don't think this a problem in master, especially after fixes like #69851. Hardware limitation still applies of course, as described above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests