-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Implement lossless WebP encoding #47835
Conversation
Some preliminary testing (release_debug build): Import performance
Runtime loading performance
I.e. in this test, WebP takes around 80% of the time to load, compared to PNG. (In fact these are all tested with 3.x. I can't get master to run without crashing all the time.) |
Meh, testing this is kind of ugly, since Directory does not support listing "res://" in exported projects. |
I am concerned that this is slower than png loading, is there any knob we can use to make WebP faster? It may be worth the loss. |
How do I enable quality 25 for a lossless import? |
I did another benchmark with png files that are a bit bigger. The WebP presets are selected with WebPConfigLosslessPreset(), which ranges from 0 to 9.
It looks like level 2 almost ties with PNG. |
I think level 2 is a good default value. In the future, you could probably expose the WebP compression level in a project setting so people can tune it to their needs. We already have similar project settings for Zstandard compression. |
@Calinou Are you sure? All the other texture compression settings (e.g. the VRAM compression quality) are in the import panel. |
Considering this is a "niche" setting that only needs to be changed on a global basis, I'd make it a project setting. In comparison, lossy or VRAM compression quality sometimes has to be changed on a per-texture basis. Lossless compression is also different from lossy compression in the sense that the compression level doesn't affect visual quality, only file size. |
I guess I'll make the force png a project setting as well then. |
There isn't a mechanism for this yet, but since this is an advanced feature, it's not that important for now. |
Nevermind, I found it. Do you think |
Sounds good to me 🙂 |
Nevermind again, invoking a re-import by restarting would become quite ugly. |
d1756eb
to
547c5e3
Compare
I think yes. |
The numbers you give look very unexpected. JPEG should generally be much faster than PNG! I don't know if Godot has multi-threaded (and/or pipelined) resource loading (yet?). |
Godot has both parallel resource importing and loading in the |
547c5e3
to
6aa0b50
Compare
Rebased to current master. |
I'll start a discussion in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fire You mean the Third Person Shooter demo? That practically uses no losslessly compressed textures, so it would hardly make any difference. |
I was trying to think of a proper test case, and yes, modifying the TPS to go from vram to lossless is strange, and we should not do it. Maybe there's a 2d game test candidate for the webp test. |
You can use the 2D platformer demo or Jetpaca for this purpose. Lossless compression is found in 2D projects and (correctly configured) pixel art 3D projects. In non-pixel art 3D projects, it's better to go for VRAM compression unless the base texture resolution is low enough to make non-VRAM compressed textures viable (e.g. porting an old game). |
The import times of Jetpaca are the same in 3.x, with and without webp. |
6aa0b50
to
1bc1e94
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved in PR review meeting today.
Thanks! |
Consider exposing webp near-lossless. You will get no visible loss if you use setting 60 and still much less loss than highest quality levels of lossy codec at setting 40. Often the filesize is 40 % smaller than full lossless. |
Godot already exposes lossy WebP encoding, while also allowing you to adjust the lossy compression quality. Note that lossy encoding doesn't save VRAM, so it's only recommended for 2D games with heavy non-pixel art textures. |
Near-lossless allows the use of yuv444 (crisper colors), and is a few db more precise than best of lossy. |
I guess near-lossless compression could be used if the lossy quality is set to |
See godotengine/godot-proposals#2593
Defaults to WebP for lossless texture compression, with a checkbox to force PNG compression.
DATA_FORMAT_LOSSY
is renamed toDATA_FORMAT_WEBP
and can be either lossy or lossless.DATA_FORMAT_LOSSLESS
is renamed toDATA_FORMAT_PNG
.Afaik, this does not cause a compatibility break, and no automatic re-import either. Maybe it should?
I have not yet performed performance testing, but at least in the Debug build, the slower importer performance at the default "quality" 70/100 is noticeable, but the files are definitely smaller. It is yet to be seen how much the Release build is affected.
Perhaps the "quality" setting can also be lowered.
Bugsquad edit: Closes godotengine/godot-proposals#2593