You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Background
CanvasItem (and RenderingServer) contains several draw_* functions which allow convenient rendering of 2D primitives such as circles and lines, with minimal setup.
The problem
Some of these functions feature optional antialiasing, which works well if the runtime window size matches the viewport's base size defined in the project settings. Unfortunately, when stretch mode is set to canvas_items (or scale factor > 1) and the window exceeds the base viewport width/height, the transparent feathers are not automatically scaled, resulting in blurry edges, as demonstrated in the MRP.
I have verified that this happens for circles, lines and rects. Using the RenderingServer functions directly yields the same results. Note that this is not an inherent limitation of these functions, because changing the viewport base size to match the screen size always results in smooth edges, even at very high resolutions.
Potential fix
It's relatively easy to achieve resolution-independent antialiasing of 2D shapes using shaders (SDF font rendering is such an example). For circles, the shader is very simple (this is included in the MRP for comparison with the default):
I've found that this also happens, regardless of window settings, when you set the scale parameter in the Node2D you're drawing from (or, I assume, generally when scaling the canvas item transform)
Setting the scale 10x:
Leaving scale at 1 but drawing everything 10x bigger and further apart:
Tested versions
System information
Windows 10.0.19045 - Multi-window, 1 monitor - Vulkan (Forward+) - dedicated GeForce GTX 765M - Intel(R) Core(TM) i7-4700MQ CPU @ 2.40GHz (8 threads)
Issue description
Background
CanvasItem (and RenderingServer) contains several draw_* functions which allow convenient rendering of 2D primitives such as circles and lines, with minimal setup.
The problem
Some of these functions feature optional antialiasing, which works well if the runtime window size matches the viewport's base size defined in the project settings. Unfortunately, when stretch mode is set to canvas_items (or scale factor > 1) and the window exceeds the base viewport width/height, the transparent feathers are not automatically scaled, resulting in blurry edges, as demonstrated in the MRP.
I have verified that this happens for circles, lines and rects. Using the RenderingServer functions directly yields the same results. Note that this is not an inherent limitation of these functions, because changing the viewport base size to match the screen size always results in smooth edges, even at very high resolutions.
Note: this is vaguely related to proposal #7309.
Potential fix
It's relatively easy to achieve resolution-independent antialiasing of 2D shapes using shaders (SDF font rendering is such an example). For circles, the shader is very simple (this is included in the MRP for comparison with the default):
Image (from the MRP)

Steps to reproduce
Import the MRP and run the example scene.
Minimal reproduction project (MRP)
blurry_draw_antialiasing.zip
The text was updated successfully, but these errors were encountered: