Home

Awesome

Antialiased Line2D add-on for Godot 4.x

Screenshot

Higher-quality, more portable antialiased Line2D and Polygon2D drawing compared to the default Godot implementation. Also features an helper node to draw circles and other regular polygons easily.

This repository only contains the add-on. See godot-extended-libraries/godot-antialiased-line2d-demo for the demonstration project.

Features

The AntialiasedLine2D add-on runs both in the editor and the running project, so you can see the line being antialiased in the editor.

Limitations

Installation

Using the Asset Library

Manual installation

Manual installation lets you use pre-release versions of this add-on by following its master branch.

git clone https://github.com/godot-extended-libraries/godot-antialiased-line2d.git

Alternatively, you can download a ZIP archive if you do not have Git installed.

Usage

[!TIP]

To improve rendering quality, set the Anisotropic Filtering Level project setting to 16× (instead of the default 4×). This particularly helps for narrow or curved lines.

Lines

Note: The Texture and Tile Mode properties are automatically set by the add-on. Changes to these properties will be lost when running the project or reloading the scene in the editor.

Polygons

Circles

How it works behind the scenes

  1. A texture with custom mipmaps is procedurally generated in GDScript to handle arbitrary line widths and zoom.
  2. The texture is generated once in an autoload and is reused. This means performance doesn't suffer when instantiating Line2D nodes at run-time.
  3. The texture is loaded in a Line2D's texture slot. The polygon or UV generation algorithm remains unchanged.
  4. The hardware automatically determines which mipmap to use, making the rendering very fast.
  5. For AntialiasedPolygon2D, it adds a Line2D as a child node to the Polygon2D and assigns the antialiased line texture to it. The line is automatically kept in sync with the polygon's points, with an additional point added so it forms a closed polyline.

License

Copyright © 2022-present Hugo Locurcio and contributors

Unless otherwise specified, files in this repository are licensed under the MIT license. See LICENSE.md for more information.