-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Improve CompressedImageSaver #14671
Description
It's time to get serious about texture speed :). Streaming mips can come later, first we need a better system that actually compresses textures (on disk).
Old plan (ignore everything under this)
The current CompressedImageSaver outputs basisu files, which tend to be quite large, as they're designed for random-access decompression on the GPU, not for linear-reads like loading from disk. We should supercompress the textures by compressing the basisu with zstd. By storing that in a ktx2, we can reuse the existing ImageLoader (ktx2 zstd-supercompressed textures are an existing standard), no need for a custom loader.
We may also want to skip basisu, and just store BC7/ASTC/etc in supercompressed KTX2 files directly, to avoid the overhead, and let us support more formats. See the optional bullet points below. If so, a lot of the bullets below are invalid.
TODO
- Rename to CompressedTextureSaver, as it's only meant to be used for 3D textures
- Enable set_rdo_uastc()
- Might also need to use set_no_selector_rdo() for normal maps? See https://docs.rs/basis-universal/latest/basis_universal/encoding/struct.CompressorParams.html#method.tune_for_normal_maps
- After converting to basisu, encode to a zstd-supercompressed ktx2
- Add docs
- Explain disk compression vs GPU compressed texture formats
- Describe the pipeline: PNG/JPEG -> basisu -> zstd -> ktx2 -> BC7/ASTC
- Note that it generates mipmaps
- Explain why you want to do this: smaller size on disk, faster rendering
- Add an example (might also want to rework the asset_decompression example to work on something other than an image, or just replace it outright)
- Add support for the GLTF extension
KHR_texture_basisu(?)- Not sure if this is needed? Bevy can already support ktx2 files that store both basisu, and suprecompressed basisu + zstd data
- (Optional) Add support for saving to either BC7 and/or ASTC supercompressed ktx2 files directly (not sure how expensive the runtime transcoding from basisu is, might not matter)
- (Optional) Add support for BC6 textures and ASTC HDR for HDR content
- (Optional) Use BC5 for normal maps