Following this topic where adding WebP support to LÖVE was discussed, I created this library as a proof of concept and utility before a potential native support.
It features the loading of WebP images and animations (as a sequence or streamed from memory). The library is kind of experimental due to factors like the WebP ABI or the integration with LÖVE, but it should work fine. Note that the FFI overhead when not JIT compiled is negligible compared to the decoding cost.
Project and documentation: https://github.com/ImagicTheCat/love-webp
Some animation uses cases comparisons:
Atlas loadImage
pros
- good compression for batches
- full control over the animation
- can be used to animate a lot of elements with different states
cons
- for small animations
Animation -> Array texture loadImages
pros
- big animations
- full control over the animation
- can be used to animate a lot of elements with different states
- animated atlas ?
cons
- memory usage/GPU limitations for long animations
Animation -> Streamed (video-like) loadAnimation
pros
- low memory usage for big and long animations (compressed frames + decoded frame)
cons
- CPU usage
WebP animations will probably cost more CPU/memory/space than equivalent Theora videos, they are not a replacement for video codecs; they have more features like alpha, duration per frame, blend/disposable method per frame, lossy/lossless per frame, etc. For example, WebP may be far more suited for a pixel art animation.
love-webp - WebP library [archived]
love-webp - WebP library [archived]
Last edited by Imagic on Mon Jul 17, 2023 4:00 pm, edited 1 time in total.
Re: love-webp - WebP library
hey thanks a lot for doing this! I haven't been able to make this work, can you please provide the shared libraries or at least point from where to get them and what files exactly do we need? Hopefully I don't have to build them myself?
Re: love-webp - WebP library
Under a GNU/Linux distribution, you probably just need to install the WebP library on the system.
It seems that only static libraries for Windows are given on the WebP website, so you need to compile the shared libraries. I could add the DLLs into the project, but I think it would be better to let people compile those themselves (well, it still may be better than having people replacing DLLs by randomly downloaded ones).
It seems that only static libraries for Windows are given on the WebP website, so you need to compile the shared libraries. I could add the DLLs into the project, but I think it would be better to let people compile those themselves (well, it still may be better than having people replacing DLLs by randomly downloaded ones).
Re: love-webp - WebP library
So this is not meant to be used in a project? slime already said unless someone makes a single file decoder then he is not adding webp, which means he is not adding webp natively since nobody will make a single file decoder and just praying to god that someone will is quite pointless. We need something that works out of box, not proof of concept.Imagic wrote: ↑Wed Mar 18, 2020 1:33 am Under a GNU/Linux distribution, you probably just need to install the WebP library on the system.
It seems that only static libraries for Windows are given on the WebP website, so you need to compile the shared libraries. I could add the DLLs into the project, but I think it would be better to let people compile those themselves (well, it still may be better than having people replacing DLLs by randomly downloaded ones).
Could you please provide all the necessary files for all the different platforms so we can make this work on windows, linux and other?
Re: love-webp - WebP library
This is the drawback of an external library with the FFI and why native support is important for LÖVE where users probably expect everything bundled with the engine.
This is meant to be used in a project, but you need to compile/get the WebP shared libraries for each target, as you would compile/get any external Lua C modules. On Windows, since everything is kind of duplicated everywhere with little diversity, I could provide DLLs and it might work fine; but that's not so easy in general.
See this as an experimental feature, harder to use, but at least we have something to work with.
This is meant to be used in a project, but you need to compile/get the WebP shared libraries for each target, as you would compile/get any external Lua C modules. On Windows, since everything is kind of duplicated everywhere with little diversity, I could provide DLLs and it might work fine; but that's not so easy in general.
See this as an experimental feature, harder to use, but at least we have something to work with.
Re: love-webp - WebP library
I understand. But I still confused what exactly I need to do to make this work. Could you make an indepth guide or give some pointers as how the process of getting this to work looks like? I've only compiled a couple of dll's in my life so I am not well versed in anything other then straightforward scripting but if you could give some pointers I am sure I could manage. Like, I don't expect you to create a course on this topic but if you could break down the process (for this specific love2d-webp purpose) into steps so that it is more digestible by someone like me - I would be very grateful.Imagic wrote: ↑Wed Mar 18, 2020 12:27 pm This is the drawback of an external library with the FFI and why native support is important for LÖVE where users probably expect everything bundled with the engine.
This is meant to be used in a project, but you need to compile/get the WebP shared libraries for each target, as you would compile/get any external Lua C modules. On Windows, since everything is kind of duplicated everywhere with little diversity, I could provide DLLs and it might work fine; but that's not so easy in general.
See this as an experimental feature, harder to use, but at least we have something to work with.
Re: love-webp - WebP library
It depends on each target, there is no (unfortunately) consistent cross-platform automated process to build binaries. There are more build systems than Lua OOP libraries and it's still a nightmare.
What are your OS/arch targets ?
What are your OS/arch targets ?
Re: love-webp - WebP library
windows>linux>mac. So if nothing else, it would be really nice to be able to get this working on windows at least for now.
Re: love-webp - WebP library
I added compiled libraries for Windows: https://github.com/ImagicTheCat/love-we ... aster/dist
For other platforms, compiling WebP would probably be a part of the app building process.
For other platforms, compiling WebP would probably be a part of the app building process.
Re: love-webp - WebP library
It works! You sir are a legend! Thank you.Imagic wrote: ↑Thu Mar 19, 2020 5:32 pm I added compiled libraries for Windows: https://github.com/ImagicTheCat/love-we ... aster/dist
For other platforms, compiling WebP would probably be a part of the app building process.
Who is online
Users browsing this forum: No registered users and 4 guests