godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 69 forks source link

Add glLineWidth to ImmediateGeometry #2490

Closed lmcdd closed 2 years ago

lmcdd commented 3 years ago

Describe the project you are working on

Similar BlockOut

1111

Describe the problem or limitation you are having in your project

There is no possibility to set line thickness

Describe the feature / enhancement and how it helps to overcome the problem or limitation

It will be possible to set the line thickness

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

ImmediateGeometry.set_line_width(thickness)

If this enhancement will not be used often, can it be worked around with a few lines of script?

I do not know how

Is there a reason why this should be core and not an add-on in the asset library?

it is logical if the possibility from GL will be in Godot

PS: excuse me for my level of english

Calinou commented 3 years ago

OpenGL line width isn't reliably supported across platforms – for instance, AMD GPUs will ignore it and treat it as if it was always 1. Even on other GPUs, it can be limited to a low value like 5, which limits its usefulness on hiDPI displays or at high resolutions in general (such as 4K).

The "proper" fix is to render lines as triangle strips. It was done in 2D by https://github.com/godotengine/godot/pull/43828, but it needs to be implemented in 3D as well.

Calinou commented 2 years ago

Closing, as there are no plans to implement this per the above hardware limitations. It's important for Godot to look as identical as possible on various GPUs, so OpenGL line width won't be exposed.

If you want to draw thick straight lines in 3D space, you can use stretched MeshInstances with CubeMeshes or CylinderMeshes. In 2D space, you can use a Line2D node (or AntialiasedLine2D add-on if you need antialiasing).

Zireael07 commented 2 years ago

@Calinou: What about the workaround you mentioned above, "lines as triangle strips"?

Calinou commented 2 years ago

@Calinou: What about the workaround you mentioned above, "lines as triangle strips"?

I think this depends on https://github.com/godotengine/godot-proposals/issues/112 first, as there is no quick way to draw hardware-based lines in 3D right now. You can use procedural mesh generation and Mesh.PRIMITIVE_LINES, but it's not something most people think about.

Also, in a game, using particle trails is likely a better idea as it's far more flexible. Hardware line drawing is best reserved to debug tools, where antialiasing is not critical.