Git Product home page Git Product logo

Comments (7)

cstrlcs avatar cstrlcs commented on June 3, 2024 1

Woah, incredible!

I wrote a comment on your pull request showing my results. It had an imense drop on size (180mb -> 1.5mb).
Works really nice! I'll keep testing with other files and bringing more feedback.

Thank you!

from godot-aseprite-wizard.

viniciusgerevini avatar viniciusgerevini commented on June 3, 2024

Hello @castroclucas. Thank you!

Wow, 180mb? It's definitely an issue. I don't know how I haven't noticed this before. I can see some of my files are also bigger than they should be. Good catch!

The first thing that comes to my head is how it creates new image resources for each frame: https://github.com/viniciusgerevini/godot-aseprite-wizard/blob/master/addons/AsepriteWizard/aseprite_cmd.gd#L312-L316

Back then I though it used the file already stored on disk, but I believe it embeds the image in the resource, duplicating it for each frame. :(

We can move this logic to the export step, lines 95 and 155, and we can use it's reference in the AtlasTexture.

Give it a try if you have time and let me know what you find. I'll try it myself tonight.

Thanks for the help and for finding this issue. :)

from godot-aseprite-wizard.

viniciusgerevini avatar viniciusgerevini commented on June 3, 2024

A simpler fix could be using imagetexture.load(...) instead of imagetexture.create_from_image(). However, this one may not work, as the spritesheet is imported on the background. Worth it a try, though.

from godot-aseprite-wizard.

cstrlcs avatar cstrlcs commented on June 3, 2024

Hello!

I changed the line from "texture.create_from_image(i,0)" to "texture.load(image)". Since the method 'load' requires a string, I used the image's path. I deleted all import folders and tried again. Nothing changed.

One thing that I noticed is that two different spritesheets will have a big difference in size, they are not proportional.

Example:
Spritesheet 1 with 90 frames -> 180mb
Spritesheet 2 with 49 frames -> 11mb

So, the .res file is not only duplicated but the growth is exponential, right?

I'm quite new to GDScript and Godot's API but I'll keep searching and if I find something, I'll update here :)

Again, thank you for your work on this project. It is being extremely useful on my game.
If you have any means of donation, I'd like to support this project. I don't have much but I would be happy to help

from godot-aseprite-wizard.

viniciusgerevini avatar viniciusgerevini commented on June 3, 2024

Thanks! I really appreciate your help. I was also able to confirm that the image is causing the issue. I've run a few tests with an animation 48x64 with 38 frames. The .png file generated has 3.2kb. Here are the results:
Screenshot from 2021-01-07 19-31-04

  • normal.res is the current import, generating a 21mb file.
  • no_texture.res was just a quick test where I removed the file generation altogether.
  • resource_loader.res I replaced the image creation with ResourceLoader.load(). This should be the way to go, but the problem is that Godot does not identify files being generated in the background so, as it was never imported before, it would always fail on the first try.
  • single_texture.res I removed the file creation logic and I replaced the logic in _parse_texture_path to get the path and create a ImageTexture, using ImageTexture.load(). This is the easiest and cleaner solution, but ImageTexture shows a deprecation notice on the load method. :(

I'll start looking into how to make ResourceLoader.load() work, maybe finding a way to trigger the image import without having to leave Godot.
The fallback option is to change the logic to use ImageTexture.load() until we find a better way.

Again, thank you for your work on this project. It is being extremely useful on my game.

I'm glad to hear it. I also benefit a lot from the community, so I try to find ways to also contribute back :D

If you have any means of donation, I'd like to support this project. I don't have much but I would be happy to help

It's really nice of you, but it's not necessary. You are already contributing a lot by taking time to help me find and fix this issue. Without your heads up, I don't know when (or whether) I would have noticed this. Thanks!

from godot-aseprite-wizard.

viniciusgerevini avatar viniciusgerevini commented on June 3, 2024

I've managed to use the resource imported by Godot. It won't work in the importer though, so I'll still use a fallback for that.
I have tested on Linux only. Tomorrow, I'll validate against Windows and MacOS. I also want validate with more diverse files before merging it.

The spritesheet I used for testing was the same as before, 48x64 with 38 frames.
Here are my latest results:
Screenshot from 2021-01-08 00-14-30
The first and second files were imported using the fallback method (Image.load()). The last two files use the resources imported by Godot (ResourceLoader.load()).

For some reason, the fallback method is still quite big. Compared to the source file, it is more than 100 times the original size. However, it's not even close to the initial 21mb.

Maybe there is something else we can do for it, but it's already a good improvement.

You can find my changes in the fix_resource_size branch.

I'll open a PR soon to explain with more details the changes and workarounds.

from godot-aseprite-wizard.

viniciusgerevini avatar viniciusgerevini commented on June 3, 2024

I've already submitted version 1.2.2 to Godot's Asset Library. It usually takes a few days to land.
Thanks again for finding this issue and helping me to debug it. I had files going from 12mb to 3.5kb in my game.
:))

from godot-aseprite-wizard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.