godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.93k stars 21.15k forks source link

Activating use_texture_padding disables mipmaps (Atlas) #78743

Open kozlown opened 1 year ago

kozlown commented 1 year ago

Godot version

v4.0.2.stable.official [7a0977ce2] v4.0.3.stable.official [5222a99f5]

System information

Ubuntu 20.04.6 LTS

Issue description

Activating property use_texture_padding for an Atlas disables mipmaps for this atlas.

Activating the property use_texture_padding should not disable mipmaps because it makes impossible the creation of clean HD-2D maps with zoom/unzoom.

image image

Steps to reproduce

  1. Create a Tilemap Node
  2. Add a new Tileset to the Tilemap.
  3. Import a new texture from an HD image with the property mipmaps/generate activated.
  4. In the Tileset Pannel, add a new Atlas using the previously imported texture.
  5. Add some tiles to the map.
  6. Try activating/disabling the property use_texture_padding of the atlas and zoom/unzoom to check if the map looks pixelated (= mipmaps not used)

Minimal reproduction project

Test use_texture_padding and mipmaps.zip

Calinou commented 1 year ago

cc @groud

I discussed this on Discord with OP. To resolve the issue, we should probably generate mipmaps automatically after creating padding if the source texture also has mipmaps enabled.

groud commented 1 year ago

I discussed this on Discord with OP. To resolve the issue, we should probably generate mipmaps automatically after creating padding if the source texture also has mipmaps enabled.

Hmm, if you take a TileSet texture and generate mipmaps for it, then pixels will end up blurred, and texture bleeding is bound to happen anyway. So I am not sure that texture padding is very useful when mipmaps are enabled (it might help, but the problem will be visible anyway).

I see several solutions: