-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lossless PNG Compression #2803
Lossless PNG Compression #2803
Conversation
This will probably break leaf and bush textures (anything for 'allfaces_optional' nodes) which need to remain RGBA to function properly in the various modes. Please read through #1831 for important points.
👎 |
Interestingly this is what most other said you would say. I'm relatively new to the community in terms of PR's.
Roughly before the end of january
This cost me roughly 45 minutes to go from scratch to writing a script to compressing every texture in MTG. It can absolutely be automated, super easily. As for file sizes, all of MTG amounts to roughly 300 KB in total media. So, removing out ~100 KB of that is a significant reduction. This 100 KB is done for every single server that every client connects to. That reduces first time load times and actually does have a significant effect on player adoption for servers. Finally, minetest is a worldwide game, many don't have access to the same bandwidth speeds you or I do. While mapblocks will dwarf 100 KB over the course of playing several hours, 100 KB is comparable to loading up spawn for most servers. Long story short, even if you don't care, others most certainly do. As evidenced by the three thumbs up this has already received. P.s. Be on the lookout for compressed .obj files next. We also send those over the wire without compression and we can shrink them by roughly 50% as well. Edit 1:I searched every lua file and these are the list of files used in allfaces_optional nodes:
So when you are looking at the updated PR, check that those are either unchanged or at least still in RGBA color mode. I will also be checking them visually, as well as checking with gimp. (though gimp is most of the reason these files are bloated in the first place, but that's a different story, I love gimp, and they deserve better compression options....) |
Okay, further update. I have reviewed every node in minetest, especially anything having to do with allfaces. I have seen no difference at all. here's the 7 nodes using the above mentioned textures. Do you see anything I'm missing? In light of this, I would push back against your assumption that allfaces has a real issue with indexed pngs. perhaps someone compressed them incorrectly? Or maybe I don't have my setup the same to recreate the issue? Unless shown otherwise, I don't see why any changes are needed to this PR or any reason not to merge.Anyways, I read through #1831, and can shed some more light on pertinent issues:
For commit one, I used:
Options explained: For Commit two, I used:
Options explained: And that's everything. The two programs result in the smallest file sizes possible out of ~6 programs I tried. YET, they have had no visible effects on the nodes from what I can find. (tried for 95 minutes to find differences...) |
Further UpdateI went and searched for the original issue and found this: #1397 I don't have the needed hardware to test if the issue has been fixed, and will now be reverted the needed textures. Coincidentally, all textures affected by that issue haven't been changed since they were fixed in 2016. I have been able to revert all 30 of the files that were displaying problems, and then removed only the metadata.The result is nearly the same size as my compression (because those weren't the bad culprits) and now we can be certain there wont be issues. |
…uanti-org#1397 Apply optipng -strip all to remove only metadata and no further compression
56755a8
to
3a7d0e8
Compare
Okay, updated and ready to be merged 👍 |
I can't reproduce this with this PR. Does it only happen on certain platforms? |
Thanks for checking out the PR Ruben, all textures that use allfaces_optional have NOT been converted into indexed mode. I have opted to use the original versions, and stripped metadata only. In fact, the original PR from 2016 that reverted those textures is what I reverted to for those textures, and it seems there were others than just allfaces_optional that caused the issue. 30 files in total were done this way. The reverting PR is: 47efa2f Edit: |
Closing this pull Request after much discussion with community and recent core dev meeting. Will be submitting a new PR with much less controversy, but similar effect. |
These two commits applied png compression to all textures in MTG using the following two utiities, in two separate commits:
https://github.com/fhanau/Efficient-Compression-Tool/releases
https://sourceforge.net/projects/optipng/
Both were set to maximum compression modes and to strip needless metadata. The resulting PNG files are lossless copies of the originals, but total texture bytes have shrunk from 247,571 Bytes to 140,719 Bytes. Or 56.84% of the original file sizes.
As a second discussion, I also tested the results of using webp to store the same information losslessly, and the result was 120066 Bytes, or 48.50% of the original file sizes. We may want to look at including webp decoding support in minetest in the future. Their license is compatible, I believe: https://www.webmproject.org/license/software/