-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Support lossless WebP for texture import #2593
Comments
If the decompression speed claims are true on all platforms (including mobile and WebAssembly), this could be a pretty good solution to decrease the file size of 2D games.
We can use lossless WebP for textures smaller than 8192×8192 and PNG for larger textures. With textures above 8192×8192, you're expected to use VRAM compression anyway due to how much VRAM a single uncompressed > 8192×8192 texture will take up.
My issue with doing this is that it introduces a fair amount of complexity and choice paralysis for casual users who already have trouble figuring out which import format they should use. I would really prefer an automatic setup for this, with a project setting for those who really want to override the importer in use (like we already do for VRAM compressors). If we go with the aforementioned automatic detection, we could have a project setting like |
Even if we keep the user-interface the same, I'd rename the constants, since they are always that specific format. |
A side note: |
We can use pregenerated mipmaps to get higher quality mipmaps without slowing down loading times. However, this isn't implemented yet since a basic box filter is currently used: #2450 |
Regarding storing mipmaps, we also want to implement proper texture streaming (loading higher level mips first) which won't work if we don't pre-generate the mipmaps. |
The purpose of this issue is to discuss the inclusion of Lossless WebP, and how to implement it best.
I am hoping to implement this myself.
Summary
Lossless WebP has faster decompression and smaller file size than PNG. See https://developers.google.com/speed/webp/docs/webp_lossless_alpha_study
Only the default encoding speed seems to be lower. (But by choosing a fast preset, it looks like it is faster and still yields a smaller size.)
WebP is already supported in Godot, but the lossless mode is not made available.
Implementation approach
Since the WebP library is already included, the implementation is mostly about how to enable the user to access it.
Completely replacing PNG with WebP is not possible, since WebP absurdly only supports image sizes up to 16383, therefore the largest power of two supported is 8192.
Larger textures may be a rare use case, but should still stay supported.
Therefore, the most sensible approach seems to be the following:
Rename the existing formats:
DATA_FORMAT_LOSSLESS
becomesDATA_FORMAT_PNG
,DATA_FORMAT_LOSSY
becomesDATA_FORMAT_WEBP
.Then, in the lossless importer mode, another checkbox (perhaps called "Use WebP") is added.
That means the
COMPRESS_LOSSLESS
can import both PNG or WebP.The text was updated successfully, but these errors were encountered: