UASTC-HDR-6x6-Support-Notes

This content was automatically converted from the project's wiki Markdown to HTML. See the Basis Universal GitHub wiki for the latest content.

Basis Universal now supports a powerful GPU-native HDR photo codec capable of handling both scene-referred and display-referred content at competitive bitrates—typically around 1.2–3.0 bits per pixel for storage/transmission, and 3.56 bpp (ASTC HDR) or 8 bpp (BC6H) in GPU memory. Both the encoder and transcoder work well in the browser (using WASM), with optional support for WASM multithreading.

As of Dec. 2024, the system supports encoding to, and transcoding from, two additional high quality formats. The first is 100% standard ASTC HDR 6x6 (3.56 bits/pixel or texel, RGB only) with or without RDO (Rate-distortion optimization), and the second is a custom variable block size compressed intermediate format that is rapidly transcodable to ASTC HDR 6x6. Both formats can also be rapidly transcoded to BC6H in real-time, or to a variety of uncompressed pixel formats for GPU devices or API's that don't support ASTC HDR or BC6H.

The ASTC HDR 6×6 codec operates in a scene-referred, linear-light color space using half-float RGB data, and supports a maximum encodable value of 65,216.0 per channel due to ASTC HDR format limits. Unlike display-referred systems that encode tone-adjusted imagery for specific display devices, this codec preserves full scene-linear luminance information, making it resilient to exposure adjustments, compositing, and physically-based rendering. The encoder is perceptually optimized using advanced visual models to guide rate-distortion decisions, ensuring high visual fidelity even at aggressive compression levels. While designed for scene-referred workflows, the codec is equally capable of handling display-referred HDR content, as well as LDR/SDR content upconverted to HDR (typically 80–100 nits or candela per sq. meter).

This encoder has been extensively tested and refined on a wide range of positive half-float HDR and upconverted LDR/SDR photographic content. It goes to great lengths to reduce block artifacts, which can be more noticeable at 6x6 vs. 4x4 pixel block sizes. Internally it operates in the ICtCp HDR colorspace (with support for values exceeding 10,000 nits), and utilizes the delta E ITP color difference metric (or see here). It's also our first encoder to heavily utilize SSIM and a perceptual saliency map to guide compression decisions. Here's a comparison showing the quality difference between ARM's astcenc encoder vs. ours.

Our future plans include extending this compressor to support a more powerful intermediate format by adding entropy coding and more effective weight grid compression, to also support other ASTC HDR block sizes, and an optional alpha channel.

The two new formats:

The compressor can write both .basis and .KTX2 files in these two texture formats, although .KTX2 is now our default file format. Both formats internally utilize the same 75 mode ASTC HDR compressor, which supports upsampled ASTC weight grids, 1-3 subsets, single or dual planes, and Color Endpoint Modes (CEM's) 7 and 11.

Note that .KTX2 files utilizing our custom intermediate format for ASTC 6x6 HDR (basis_tex_format::cASTC_HDR_6x6_INTERMEDIATE) are currently only readable using our library/tools (as of 2/2025). We're still working with Khronos on the exact header ID's we use in this mode. This doesn't apply to basis_tex_format::cASTC_HDR_6x6 files (RDO), which closely follow the existing .KTX2 specification which already supports RDO encoding+Zstd supercompression.

Transcoder GPU Texture/Pixel Format Support

The transcoder can output the following GPU texture or pixel formats from either type of ASTC 6x6 HDR texture (standard or intermediate):

basisu Command Line Tool Options

Note these map directly to low-level codec configuration settings in basis_compressor_params (in encoder/basisu_comp.h):

Note the "comp level" setting controls the quality vs. encoding speed tradeoff, which is not to be confused with "lambda", which is the bitrate (file size) vs. quality tradeoff.

For HDR inputs, lambda values between 100-3,000 or so work well. For LDR/SDR inputs, values between 500-50,000 work well.

The comp level setting controls the maximum number of ASTC modes and partition patterns that may be evaluated for each block.

-hdr_6x6_comp_levels X Y or -hdr_6x6i_comp_levels X Y: Directly sets the low-level 6x6 HDR codec's base and maximum internal compression vs. encoding comp levels, where X and Y range from [0,4]. Use instead of the higher level -hdr_6x6_level or -hdr_6x6i_level parameters.

-hdr_6x6_brute_force_pats, -hdr_6x6_extra_pats: Controls how partition patterns are chosen.

-hdr_6x6_no_gaussian: Disable Gaussian filtering fallback passes on blocks with low SSIM's (faster).