-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Opacity with line 2d and anti-aliasing on causes visible wireframe/"ghost" lines to appear #35878
Comments
I think it's the anti-aliasing effect overlapping over the polygons rather than debug boxes. |
As @YeldhamDev said, I'm not sure if anything can be done about it given the current antialiasing implementation. It could be redone entirely to work like StyleBoxFlat's antialiasing, but that's a fair amount of work which should probably be done after the switch to Vulkan. |
How is it possible that AA makes triangles of the line visible? They are even supposed to be shared vertices, there is no way they would overlap like that and show as if they were wireframe Oo |
I guess this is again an attempt at faking AA somehow? If it tries to draw a line on the edges of the polygon, it is doing a mistake by also drawing the inside triangles. It looks like a buggy solution to me, for ANY kind of polygon, not just Line2D, here in beta4: It was fixed for opaque polygons in beta5, but transparent ones still have a thin brighter outline with AA, and Line2D wasn't fixed: #33857 (comment)
Still, these kinds of problems remind me of #35279, I wish we simply had proper AA rather than complicated workarounds like this... The second example in your screenshot shows a different algorithm using round joints, so yeah you get different results. It will look more like This kind of problem has been around for years... one way to never get overlap is to pre-draw the geometry opaque in a viewport and draw the result with transparency, but in Godot 3.2 it's quite overkill. |
Yes, that was the idea. Similar to draw_line, although i concur a better antialiasing strategy would be the better approach. TBH. as is: i'd say line rendering with translucency is broken and this should at least be noted in the docs. /kinda offtopic, sorry: |
@Zylann I think I understand the first part is to use draw functions on a canvas, but what do you mean by draw the result with transparency? |
@avencherus It means you should render an opaque line to a viewport, and display the resulting ViewportTexture with a modulate value that makes it translucent. If the line doesn't need to be updated, this should be even faster than rendering it directly (at the cost of overdraw). |
Still seems reproducible in the current In |
As a workaround, use https://github.com/godot-extended-libraries/godot-antialiased-line2d which supports translucent antialiased 2D lines. |
Hi all. I encountered this issue in version 3.6, and the solution to the problem is actually quite simple. Godot applies antialiasing to the edges to smooth polygons. What causes this issue is the overlapping lines within the polygon. Managing these collective polygon drawings together and preventing the drawing of lines if 2 lines overlap will give the most accurate result. In my own application, I first draw the polygon with antialiasing disabled, and then I draw 1-pixel antialiased lines on the edges using draw_line. I didn't need an algorithm like checking for overlapping lines in my sample. I made exceptions for which lines should not be drawn, and my problem was resolved. Antialiased polygon formula of Godot= polygon + 1px antialiased edges So you can try to make an antialiased polygon with this formula and you can see it's the same thing with the antialiased polygon of Godot. In this way, you have the chance to determine which edges to cancel. When drawing multiple polygons simultaneously, you can prevent the issue by not drawing lines on overlapping adjacent edges. I hope it has been explanatory; if not, I can provide further clarification. |
Not sure if this is as it supposed to be or not... But might as well try submit a bug to see if it is one.
Godot version:

3.2 stable
OS/device including version:
Windows 10 1903
Issue description:
Line 2d shows debug boxes when anti-aliasing is enabled and material is translucent (i.e. 0 < alpha < 1). Example below
Steps to reproduce:
New project
Add Line2d
Add some points
Set default color alpha to be <1, e.g. 0.5
Make width larger (to better see effect), e.g. 30 - 50
Enable anti-aliasing under 'border'
The text was updated successfully, but these errors were encountered: