-
Notifications
You must be signed in to change notification settings - Fork 268
Using Basis Universal to decompress any supported GPU texture format
Rich Geldreich edited this page Mar 20, 2020
·
12 revisions
The Basis Universal encoder codebase contains easy to use code to unpack the following compressed GPU texture formats:
- BC7 - Fully supported
- ASTC - LDR only (HDR is in the code, but remarked out until we need it) Our high-level helpers only support 4x4 block size, but you can access the low-level ASTC code directly (in basisu_astc_decomp.h) to unpack other ASTC block sizes.
- BC1-5 - Fully supported
- ETC1 - Fully supported
- ETC2 RGBA8 - Only supports ETC1 for color data (no planar, T/H modes), alpha data is fully supported
- ETC2 EAC R11/RG11 - Fully supported
- PVRTC1 4bpp RGB/RGBA - Fully supported
- PVRTC2 - Limited support. Just the non-interpolated mode our transcoders use.
- ATC RGB/RGBA - Fully supported
- FXT1 - Limited support (just the mode we use)
Before you can unpack textures, be sure to call basisu_encoder_init() once at startup.
To unpack individual 4x4 (or 8x4 for FXT1) texel blocks to raw RGBA pixels, use this function: bool basisu::unpack_block(texture_format fmt, const void *pBlock, color_rgba *pPixels);
This doesn't work on PVRTC1 textures, because the decoder needs access to the surrounding blocks. Alternately, you can create a basisu::gpu_image object, then call gpu_image::unpack(). This works on any supported format, including PVRTC1.