vichui / atlas_importer3

Atlas importer plugin for other texture pack tools
MIT License
7 stars 2 forks source link

Atlastex size. #3

Open ApmeM opened 2 years ago

ApmeM commented 2 years ago

Hi,

I have a question about atlas tex size and the result package size. I took Kenney's atlas from https://kenney.nl/assets/space-shooter-redux Original texture is about 147 kb After I convert it to list of atlastex with this plugin I got 294 files of type atlastex 4097Kb each. So in total from 147 Kb it creates about 300 * 4Mb = 1.2 Gb of data. There is no way to exclude unused items from folder - so all those 1.2Gb is always included into result. I can see there are 2 problems:

  1. Idea of atlas texture is broken - the idea is to use single texture and list of regions to reduce result size and number of data access. Here it stores full image for each texture and each texture is stored separately.
  2. Kenney's assets already contains per-sprite images which is smaller and do not require logic for extracting sprite region.

***Suggestion:

Why not to store it as a *.tres file with just a text content like

[gd_resource type="AtlasTexture" load_steps=2 format=2]

[ext_resource path="res://art/ships.png" type="Texture" id=1]

[resource]
flags = 4
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 40, 40 )

It will still work in godot in a same way as atlastex (even small icons will be displayed in godot editor), but now it will work as real atlas texture.

ApmeM commented 2 years ago

After further investigation I find there is a change required according to warning in console:

WARNING: ResourceLoader.has() is deprecated, please replace it with the equivalent has_cached() or the new exists().

there are 2 usages of this 'has' method. if change both to 'exists' and result file extension to .tres it starts working properly.