Godot: Polygon2D Anti Alias issue with Textures

Created on 18 Aug 2020  路  8Comments  路  Source: godotengine/godot

Godot version:

3.2.2 Stable

OS/device including version:

MacOS, tried both with GLES2 and GLES3

Issue description:

For some reason, Textures inside a Polygon2D are rendered awfully bad when scale is set to a number that makes the image smaller than it's real size.
I also tested with Line2D, and the issue is the same.

In my editor, they look fine, but when I run the scene, I see something completely different.
Here's an image for reference:

Screen Shot 2020-08-17 at 21 15 20

Steps to reproduce:

  1. Create a blank project.
  2. Add a Polygon2D to your scene and Draw some Shape.
  3. Add Godot Icon as the Texture for the Polygon.
  4. Set scale to 8 or 10.
  5. You should see some Anti Alias in your Editor
  6. When you run the scene, you should see a very messy texture being repeated!

Important Note:

I did some research and noticed several Github Issues related to the anti alias issue in 2D, however, I'm not sure if the problem from this Ticket is an issue that Godot team is working or it's something I'm doing wrong.

Could someone clarify the status of these Anti Alias issues?

It worth to say that I tried to change Quality settings, adding Filtering, Mipmaps, disabling HDR, changing from GSL3 to GSL2, and none of these changes made the texture looks better

Minimal reproduction project:
I haven't created a project because it's super trivial

archived editor rendering

Most helpful comment

Hey @lawnjelly @Calinou !

First of all, thanks for your help, this proximity to Dev members and community support is exactly the kind of thing that made me left Unity, thanks for all your hard work in this project!

Secondly, I wanted you to know that I've became a contributor to Godot on Patreon from this day on because of this issue, especially because of the detailed response of @lawnjelly and his patience to explain concepts that may seem obvious for you already.

I will try the proposed solutions and see how they fit my project!

All 8 comments

Anti-aliasing can be enabled/disabled per texture at import. See the import documentation.

If I understand correctly, what you may want to disable is the "Filter" flag.

Hey @Rubonnek ,
How are you?

Thanks for helping me!
However, I'm afraid It doesn't work the way you say, or maybe I'm doing something wrong.

I have hosted the project on Github, so you can clone and see with your own eyes.
https://github.com/renatodex/godot-antialias-issue-41343

For the purpose of illustration, take a look at how clear and sharp (and by sharp I say "well aliased") the image looks in my editor screen, and look of how the image look when I run the build:

image

From top-left to bottom-right you have the following objects:

  1. A Polygon 2D with scale 1.
  2. A Polygon 2D with scale 5.
  3. A Texture Rect resized down manually.
  4. A Polygon 2D with a larger horizontal image. (which is looking awfully horrible!)

Either I don't know exactly how to setup this images for import or there is a clear issue with how the images are being rendered.

Oh, I see. What you are referring to now. That does indeed seem like a graphical bug.

Rendering is not my forte and I'm unable to assist further since I can't reproduce the problem because I don't have access to Mac OS.

Pinging @lawnjelly, @clayjohn.

I can't check out your first OP because it doesn't include the project, but I suspect the issues are to do with mipmapping. It looks like in the first diagram the texture has been imported not using mipmapping, but I can't tell because you don't include the project.

I don't see any difference with your second project (the one on github) on my hardware (or am not sure what you are referring to as problematic).

I suspect what you are seeing is also due to mipmapping.

Mipmaps are used to reduce aliasing when viewing textures at a distance or zoomed out. However, the choice of which mipmap to use at any zoom is not controllable from the engine code, that is done by the GPU and GPU settings, so the result you see on one device can be different to what you see on another (this is to some degree outside our control).

Often a GPU will come with a settings panel that will let you adjust between high quality and high performance. When you choose high performance, it might choose lower mipmaps sooner (i.e. blurrier textures) because these are better for performance.

It is also possible the (whole screen) anti aliasing settings are affecting which mipmap is used. BTW mipmaps, texture filtering all help with aliasing, we normally use the term anti-aliasing to refer specifically to _whole screen anti-aliasing_ (hence I'm slightly confused by what you mean), whether whole screen anti aliasing has anything to do with this.

I notice as well you are selecting filters->use_nearest_mip_map_filter. Try turning that off and see if that gives you more favourable results. It could be that is being overridden in the editor but not in the run project.

In the second project, your import settings seemed different for the 2 textures. For godot icon filter and mipmaps was on, and the wall texture they seemed off. Note that in order to see differences after changing any of these, you have to click 're-import' on the texture in the 'Import' tab.

If this isn't a bug, it could well be that the documentation could be improved, or some tutorials to aid understanding of how mipmapping and filtering work. It may be that we are assuming that people will have prior knowledge of how mipmaps work.

See:
https://en.wikipedia.org/wiki/Mipmap
https://en.wikipedia.org/wiki/Texture_filtering
https://en.wikipedia.org/wiki/Trilinear_filtering

When you turn on nearest mip map filter, it uses only either point filtering (no filter) or bilinear filtering. When you turn it off (default) it blends between the results of the 2 nearest mipmaps. This is slower but gets rid of jarring changes in mipmaps, and the experience of it seeming to use a too low mipmap (which I think is what you are referring to).

The reason for the different rendering between the editor and running project is simple. The running project is using macOS' lowDPI fallback and is therefore displayed at 2脳 zoom. Enable Display > Window > Dpi > Allow Hidpi in the Project Settings to solve this (but keep in mind this will decrease performance, and your game must support multiple resolutions).

PS: When you see screenshots of macOS in an issue report, always click them to view them at full resolution and determine whether the issue is related to hiDPI or not :wink:

That said, try to reproduce this bug after enabling Allow Hidpi, configuring the stretch mode to 2d and the stretch aspect to expand. We can reopen this issue if it still occurs with Allow Hidpi enabled.

Hey @lawnjelly @Calinou !

First of all, thanks for your help, this proximity to Dev members and community support is exactly the kind of thing that made me left Unity, thanks for all your hard work in this project!

Secondly, I wanted you to know that I've became a contributor to Godot on Patreon from this day on because of this issue, especially because of the detailed response of @lawnjelly and his patience to explain concepts that may seem obvious for you already.

I will try the proposed solutions and see how they fit my project!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timoschwarzer picture timoschwarzer  路  3Comments

blurymind picture blurymind  路  3Comments

nunodonato picture nunodonato  路  3Comments

Spooner picture Spooner  路  3Comments

ducdetronquito picture ducdetronquito  路  3Comments