Page 1 of 1

Add support for AVIF

Posted: Mon May 03, 2021 2:47 pm
by alexman91
please allow the game to use avif its much more efficient and smaller.
my mod folder is taking up 4gb of png files this can be reduced by 70% with avif.
there are batch apps to convert all png to avif lossless

Re: Add support for AVIF

Posted: Tue May 04, 2021 6:36 am
by ssilk
Doesn’t make much sense, because it needs to be unpacked when loading, which takes up some more time. Then it seems to be a non-loseless kind of compression which is bad , because in Factorio every pixel counts. And unpacked into memory the images have the same size, because that’s what’s done to make the graphics fast... I would mean the prize for 3 GB on your hard disk is much cheaper, than these disadvantages. ;)

Re: Add support for AVIF

Posted: Tue May 04, 2021 11:43 am
by ptx0
alexman91 wrote:
Mon May 03, 2021 2:47 pm
please allow the game to use avif its much more efficient and smaller.
my mod folder is taking up 4gb of png files this can be reduced by 70% with avif.
there are batch apps to convert all png to avif lossless
4gb of disk space is a problem? it is not 1998

Re: Add support for AVIF

Posted: Tue May 04, 2021 4:33 pm
by coderpatsy
ssilk wrote:
Tue May 04, 2021 6:36 am
Then it seems to be a non-loseless kind of compression which is bad , because in Factorio every pixel counts.
As mentioned in the OP, AVIF does have a lossless mode. I've no clue about unpacking time/memory so your other points probably still stand though.

Re: Add support for AVIF

Posted: Wed May 05, 2021 2:15 am
by ssilk
Avif sucks hard for lossless compression.

See https://jakearchibald.com/2020/avif-has-landed/ (-> flat illustration)

If that’s all true, then lossless WebP seems to perform better. But for these 10-20% - I don’t know if that makes sense. :)

Re: Add support for AVIF

Posted: Wed May 05, 2021 7:51 pm
by ptx0
ssilk wrote:
Wed May 05, 2021 2:15 am
Avif sucks hard for lossless compression.

See https://jakearchibald.com/2020/avif-has-landed/ (-> flat illustration)

If that’s all true, then lossless WebP seems to perform better. But for these 10-20% - I don’t know if that makes sense. :)
generally the tradeoff is in the size vs performance. better compression is going to be slower both in decompression and compression. so, you'll sacrifice load times.

overall a bad idea for no gains

Re: Add support for AVIF

Posted: Wed Aug 17, 2022 9:36 pm
by Hornwitser
There's more to it than just disk space, the mod portal currently has a maximum file size of 262.1 MB and we already see mod authors employing lossy PNG compression in order to make their mods fit into that file size limit. Supporting AVIF would enable mod authors to deliver higher quality sprites in less space than lossy PNG compression does.

Take for example the animated dish in Space Exploration, the original PNG sprite sheet (left) is 36 MB and compressed with pngquant to reduce the file size to 12 MB (middle), if AVIF was supported it could be used instead to compress it to 6 MB (right) while IMHO looking better than the pngquant output.
comp.png
comp.png (2.4 MiB) Viewed 1888 times
Notice how the reduced colour palette of the pngquant version causes very visible dithering in the top left shadow and the edges of the circuit wire. The AVIF compression does not have this issue and more colourful sprites would make the visual difference between pngquant and AVIF even greater.

Re: Add support for AVIF

Posted: Wed Aug 17, 2022 11:28 pm
by FuryoftheStars
Hornwitser wrote:
Wed Aug 17, 2022 9:36 pm
There's more to it than just disk space, the mod portal currently has a maximum file size of 262.1 MB and we already see mod authors employing lossy PNG compression in order to make their mods fit into that file size limit. Supporting AVIF would enable mod authors to deliver higher quality sprites in less space than lossy PNG compression does.

Take for example the animated dish in Space Exploration, the original PNG sprite sheet (left) is 36 MB and compressed with pngquant to reduce the file size to 12 MB (middle), if AVIF was supported it could be used instead to compress it to 6 MB (right) while IMHO looking better than the pngquant output.

comp.png
Notice how the reduced colour palette of the pngquant version causes very visible dithering in the top left shadow and the edges of the circuit wire. The AVIF compression does not have this issue and more colourful sprites would make the visual difference between pngquant and AVIF even greater.
I honestly almost can't tell the difference without magnifying them even further, and considering they will be smaller than this even in normal gameplay, I'd say the concerns around load times and performance are more important (to me personally).

As for the mod portal, that's easy to solve: advocate for the size limit to be raised. 'Cause, yeah, disk space is cheap in comparison these days.

--------------------------------------

Edit: Just to add (for general purpose of the thread, not a direct reply to the quoted post above), while I am for increased quality of sprites and all, I am not for it if it impacts game performance. I do have and use some HD graphics mods. But if any mod I played used a graphics format that slowed down game loading/play significantly (such as using this AVIF format), I'd probably ask if they could release a version that doesn't use it (defeating the purpose, yes?), and if they declined, then I'd probably drop the mod. As it was, I was very close to dropping the HD graphics mods I used because of their impact on load time (which was all data stage script related) until the devs released that update that greatly sped up the process.

Re: Add support for AVIF

Posted: Thu Aug 18, 2022 1:44 pm
by Hornwitser
FuryoftheStars wrote:
Wed Aug 17, 2022 11:28 pm
I'd say the concerns around load times and performance are more important (to me personally).

As for the mod portal, that's easy to solve: advocate for the size limit to be raised. 'Cause, yeah, disk space is cheap in comparison these days.
The file format makes no difference to the performance of the game. No matter the image format they will all be converted to the same RGB texture format when loaded on the GPU. Since you say disk space is of no concern and load times is everything then there's already a great solution for you: Turn on cache-sprite-atlas and have a couple of GB of disk space wasted to make the game load faster by caching the RGB textures that would be loaded onto the GPU uncompressed on your hard drive.

Re: Add support for AVIF

Posted: Thu Aug 18, 2022 2:23 pm
by FuryoftheStars
Hornwitser wrote:
Thu Aug 18, 2022 1:44 pm
The file format makes no difference to the performance of the game. No matter the image format they will all be converted to the same RGB texture format when loaded on the GPU.
Ok, but they do affect load time. The AVIF format sounds like it would take longer for the game to load than png. Again, I already almost abandoned some other mods over their affect on the load time and that was over the data stage script, not the actual decompression/conversion of the images.
Hornwitser wrote:
Thu Aug 18, 2022 1:44 pm
Since you say disk space is of no concern and load times is everything then there's already a great solution for you: Turn on cache-sprite-atlas and have a couple of GB of disk space wasted to make the game load faster by caching the RGB textures that would be loaded onto the GPU uncompressed on your hard drive.
To my last understanding, if anything changes, it dumps and reloads the whole set (and considering how often I'm changing things, that makes it near worthless for me) and is an experimental feature that is not 100% known to be stable or supported.

I did give it a try once upon a time, though. For me, it seemed to have a very minor impact. *shrug*

Re: Add support for AVIF

Posted: Thu Aug 18, 2022 2:58 pm
by Nosferatu
Can anyone point to a decoding benchmark?
I only found encoding and quality tests.

Re: Add support for AVIF

Posted: Thu Aug 18, 2022 11:22 pm
by Shadow_Man
Maybe JPEG XL will be better choice?
As fast as JPEG, but much more higher quality than other HD graphics formats (HEIF, AVIF etc).
Lossless compression, animation supprt and more...
https://jpegxl.info/

Re: Add support for AVIF

Posted: Fri Aug 19, 2022 5:52 am
by Koub
I was thinking it would be ironical if the devs Bloated Factorio with all these fancy new better image formats support and made Factorio heavier by tens or hundreds of megabytes for all the players, just to shave off a Gb from the mods folder for a handful of players who play with huge mod packs.