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

Custom Drawing 2D: Add section on drawing anti-aliased lines #2379

Closed
bitbutter opened this issue Apr 15, 2019 · 1 comment · Fixed by #5746
Closed

Custom Drawing 2D: Add section on drawing anti-aliased lines #2379

bitbutter opened this issue Apr 15, 2019 · 1 comment · Fixed by #5746

Comments

@bitbutter
Copy link
Contributor

Currently the custom drawing in 2D tutorial demonstrates how to create aliased lines only:
https://docs.godotengine.org/en/latest/tutorials/2d/custom_drawing_in_2d.html

For many use cases, dynamically drawn antialiased lines are necessary to match an existing game aesthetic (e.g. a dynamically drawn HUD targeting display in a futuristic FPS, or trajectory preview in a minimalist 2d artillery/angry birds game). I think the article needs the addition of information on how to achieve dynamically drawn antialiased lines.

This is motivated by a personal need! In Unity I used the Vectrosity plugin to draw antialiased lines, I'm wondering how to do this in Godot.

@Calinou
Copy link
Member

Calinou commented Apr 15, 2019

I think this functionality should be added in core for all kinds of 2D line drawing. Currently, draw_line() offers an antialiased parameter but it doesn't work well in all situations (e.g. with translucent lines). See godotengine/godot#12840 and godotengine/godot#8289.

As a workaround, you may be able to use Line2D/Path2D + Curve2D with a texture that features an one-pixel gradient on the top and bottom edges — see this example project I made. It works quite well with constant line widths, but antialiasing won't look as good if the line width is variable (since the gradient may end up being too thin or too thick for the displayed size).

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

Successfully merging a pull request may close this issue.

2 participants