goblinengine / goblin

Goblin Engine custom build of Godot
https://goblinengine.github.io
MIT License
12 stars 2 forks source link

Implement APNG support. #1

Open sairam4123 opened 2 years ago

sairam4123 commented 2 years ago

I'm working on a project that requires APNG support, it's more than 100 frames and can't be converted to sprite sheet. Do you think would it be feasible to implement it too? Thanks!

filipworksdev commented 2 years ago

I looked into it. There's a lot of different opinions on this see for example here where is also mentioned that libpng (which Godot uses) has a patch for apng found here.

So is doable. Would require core changes patching Godot's libpng with apng support, extract apng frames into AnimatedTextures res, custom importer to detect the .apng file and auto import and probably also a function that loads apng and spits out AnimatedTexture object.

I got only two concerns:

  1. I'm not opposed to core changes just wanna make sure they are kept light as is a huge pain to maintain between Godot 3.x updates and I plan to keep Goblin 3.x binary compatible (so everything you can do on 3.x you can do here + extra)
  2. apng is very useful but not popular at all see here for ex

Godot does have thedatastructure to hold such a file though image

In fact I'd take a PR for this if someone is interested in implementing it as well otherwise I'd take a stab at it as some point. I'm not opposed to this at all.

filipworksdev commented 2 years ago

You are also welcome to join the discord server for Goblin if you wish https://discord.gg/erpDN9yUxN so we can discuss this further.

filipworksdev commented 2 years ago

I looked into this further.

libwebp library that is used in Godot has the ability to decode animated webp https://github.com/goblinengine/goblin/blob/main/thirdparty/libwebp/src/demux/anim_decode.c but that functionality is never implemented in the webp module here https://github.com/goblinengine/goblin/blob/main/modules/webp/image_loader_webp.cpp . Instead of apng you could add the missing animated webp functionality such that it created an AnimatedTexture object if webp has frames.

Converting from apng/gif to webp animated is super easy and webp supports both lossy and lossless. WebP is also much more popular and commonly supported than apng. So this is another way that it could be done.

Fazyrus commented 1 year ago

I've been looking for a way to load animated WebP files in Godot for a project I'm working on and I found this post, I don't really know how to implement it myself, would it be difficult to make something like that work?

filipworksdev commented 1 year ago

I've been looking for a way to load animated WebP files in Godot for a project I'm working on and I found this post, I don't really know how to implement it myself, would it be difficult to make something like that work?

To implement something like this without knowing anything is going to be hard. If you have implemented anything like this before in C++ is also going to be hard because Godot Engine is badly written spaghetti code software. Nothing makes sense in how is organized and written.

Honestly I would not bother. Just give up on Godot there are way better engines out there haha I spend 90% of my time fixing someone else's bad code.

Fazyrus commented 1 year ago

Switching to another engine isn't really an option for me since I already got pretty far with my project, and I got pretty much everything I need working except for the WebP files. I have very little experience with C++ though so I can imagine it would be pretty difficult for me to try implementing it. If you could give me any tips on how to do it or what exactly needs to be done to make it work, I would really appreciate it!