Skip to content
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

Added WebP image format support #8220

Merged
merged 3 commits into from Mar 28, 2023
Merged

Conversation

KernelFreeze
Copy link
Contributor

Objective

WebP is a modern image format developed by Google that offers a significant reduction in file size compared to other image formats such as PNG and JPEG, while still maintaining good image quality. This makes it particularly useful for games with large numbers of images, such as those with high-quality textures or detailed sprites, where file size and loading times can have a significant impact on performance.

By adding support for WebP images in Bevy, game developers using this engine can now take advantage of this modern image format and reduce the memory usage and loading times of their games. This improvement can ultimately result in a better gaming experience for players.

In summary, the objective of adding WebP image format support in Bevy is to enable game developers to use a modern image format that provides better compression rates and smaller file sizes, resulting in faster loading times and reduced memory usage for their games.

Solution

To add support for WebP images in Bevy, this pull request leverages the existing image crate support for WebP. This implementation is easily integrated into the existing Bevy asset-loading system. To maintain compatibility with existing Bevy projects, WebP image support is disabled by default, and developers can enable it by adding a feature flag to their project's Cargo.toml file. With this feature, Bevy becomes even more versatile for game developers and provides a valuable addition to the game engine.


Changelog

  • Added support for WebP image format in Bevy game engine

Migration Guide

To enable WebP image support in your Bevy project, add the following line to your project's Cargo.toml file:

bevy = { version = "*", features = ["webp"]}

@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@mockersf
Copy link
Member

Thanks!

Could you run this command and commit the modified file?
cargo run -p build-templated-pages -- update features

@mockersf mockersf added the A-Assets Load files from disk to use for things like images, models, and sounds label Mar 26, 2023
@KernelFreeze
Copy link
Contributor Author

Could you run this command and commit the modified file? cargo run -p build-templated-pages -- update features

Sure! I added the documentation with that command

@superdump
Copy link
Contributor

Do we normally note when features depend on C/C++ libraries? That may be useful information for users to understand when there is no wasm support. It looks like the webp feature in the image crate depends on a C library.

@KernelFreeze
Copy link
Contributor Author

Do we normally note when features depend on C/C++ libraries? That may be useful information for users to understand when there is no wasm support. It looks like the webp feature in the image crate depends on a C library.

It only uses libwebp when encoding but that is not enabled here 😊

@KernelFreeze
Copy link
Contributor Author

Also, this supersedes #2600, as the other pull request imports a C library and uses an old asset-loading system.

@james7132 james7132 added C-Enhancement A new feature A-Rendering Drawing game state to the screen labels Mar 28, 2023
@mockersf mockersf added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Mar 28, 2023
@mockersf mockersf added this pull request to the merge queue Mar 28, 2023
Merged via the queue into bevyengine:main with commit 95aa387 Mar 28, 2023
25 of 27 checks passed
@KernelFreeze KernelFreeze deleted the webp-support branch March 28, 2023 20:52
@DGriffin91
Copy link
Contributor

DGriffin91 commented Mar 28, 2023

@KernelFreeze Note that your comment regarding "reduced memory usage" would only potentially apply while in the process of loading the image. Once it's loaded it will be stored in ram and vram raw and uncompressed. To reduce ram and vram usage a GPU compressed format should be used. (like KTX2 files with BCn compression for example)

I do however believe this is a worthwhile feature. Thanks for working on it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds A-Rendering Drawing game state to the screen C-Enhancement A new feature S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants