-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Compressed texture support #3608
Copy link
Copy link
Closed
Labels
A-RenderingDrawing game state to the screenDrawing game state to the screenC-FeatureA new feature, making something new possibleA new feature, making something new possible
Description
Description
- Support DDS, KTX2, and Basis Universal compressed textures
- Support loading them from gltf
Solution
- [Merged by Bors] - KTX2/DDS/.basis compressed texture support #3884
- Generic compressed texture support
- Load compressed texture data as-is by adding
create_texture_with_datatoRenderDeviceand using it - When preparing the
GpuImage, if it is a compressed format, useRenderDevice::create_texture_with_datawith the specified format, which includes all mipmaps. If it is not compressed, copy mipmap level 0 only as before. - Explicitly specify whether a texture to be loaded from a buffer is sRGB or linear at load time. For glTF textures are marked as being linear or not and this is used to indicate sRGB or not.
- Respect platform-supported compressed formats
- Add
CompressedImageFormatsflag type withASTC_LDR,BC, andETC2flags to match what is supported bywgpu::Features - Add a
supported_compressed_formatsmember toImageTextureLoaderandGltfLoaderand populate it based onWgpuOptionsat loader-initialisation-time. - When loading an
ImageusingImage::from_buffer(), pass theCompressedImageFormatsstored in the loader to inform the load() about whether compressed formats are supported, and/or about formats to transcode to, in case of universal compressed formats such as UASTC/ETC1S.
- Add
- Load compressed texture data as-is by adding
- DDS
- Load raw data from DDS files, using the
ddsfilecrate, intoImageand set the correct image format. Note that this includes all mipmaps. - Map all DDS formats, both D3D and DXGI to wgpu texture formats
- Load raw data from DDS files, using the
- KTX2
- Load raw mip level data from KTX2 files, using the
ktx2crate, intoImageand set the correct image format. Note that this includes all mipmaps. - Map all KTX2 formats to wgpu texture formats
- KTX2 supercompression support
- Parse the Data Format Descriptor and Sample Information sections of the KTX2 header to get all the necessary information needed to identify the format. PR here: Data format descriptor BVE-Reborn/ktx2#4
- ZLIB using
flate2which in turn usesminiz_oxidewhich is a rust DEFLATE implementation - Zstandard using
ruzstdwhich is a rust Zstandard decompressor
- Transcoding from KTX2 UASTC to an appropriate format using the
basis-universalcrate which uses bindings to the C++ Basis Universal library
- Load raw mip level data from KTX2 files, using the
- Basis Universal
.basisfile support for ETC1S/UASTC with transcoding to an appropriate format, also using thebasis-universalcrate
- Support for 2-component normal maps stored in the red and green channels, deriving the third component assuming the stored normal is a unit normal.
Next Steps
- WASM target support for both
.basisfiles and transcoding UASTC from KTX2 files. The basis-universal library has been compiled to WASM. It is possible to call other JavaScript code from rust code compiled to WASM using C-style FFI so maybe it will work for WASM to WASM as well? - KTX2 BasisLZ supercompression support. BasisLZ is quite non-trivial so I feel like it is reasonable to only support it via
.basisfiles to start with.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-RenderingDrawing game state to the screenDrawing game state to the screenC-FeatureA new feature, making something new possibleA new feature, making something new possible