Why BC4 Is Best for Grayscale Maps in DirectX
BC4 (Block Compression 4) is a specialized GPU texture compression format designed specifically for single-channel data, making it the industry standard for grayscale maps such as roughness, gloss, and height in DirectX. By dedicating all of its data budget to a single 8-bit channel, BC4 achieves a 2:1 compression ratio relative to raw 8-bit textures while avoiding the multi-channel compression artifacts and memory waste typical of color-oriented formats like BC1 or BC7.
Dedicated Single-Channel Footprint
Standard color compression formats (such as BC1, BC3, or BC7) are built to compress RGB or RGBA data. If an engine stores a single grayscale map in a standard RGB format, it redundantly duplicates the grayscale value across all three color channels, consuming unnecessary memory bandwidth.
BC4 operates natively on single-component textures
(DXGI_FORMAT_BC4_UNORM and
DXGI_FORMAT_BC4_SNORM). It compresses a 4x4 block of 8-bit
pixels into 64 bits (8 bytes), resulting in a fixed footprint of 4 bits
per pixel (bpp). Compared to an uncompressed 8-bit single-channel
texture (DXGI_FORMAT_R8_UNORM) at 8 bpp, BC4 cuts VRAM
usage and memory bandwidth consumption directly in half.
Superior Gradient Precision and Endpoint Interpolation
BC4 utilizes the same encoding scheme as the alpha channel block in BC3 (DXT5). Within each 4x4 block, the encoder stores:
- Two 8-bit reference values (endpoints).
- A 3-bit index for each of the 16 pixels.
Depending on the relative values of the two endpoints, the hardware mathematically interpolates either six or four intermediate values between them (along with fixed values for fully black and fully white). Because each pixel can select from eight possible steps between the two endpoints, BC4 provides smooth gradient transitions across small areas. This high local precision prevents the visual banding and stair-stepping that ruin subtle roughness variations or continuous terrain heightmaps.
Elimination of Cross-Channel Compression Artifacts
When grayscale information is stored alongside other maps inside a multi-channel format (such as an RGB pack using BC1), the compression algorithm calculates an error metric based on all channels combined. Color-based formats often sacrifice detail in one channel to preserve fidelity in another.
BC4 eliminates this issue entirely by evaluating and optimizing errors strictly for the single scalar channel. Height maps retain clean edges without color bleeding, and roughness maps maintain the exact surface micro-detail intended by artists.
Native Hardware Decoding and Shader Simplicity
DirectX hardware from Feature Level 10_0 onward provides full, native decoding support for BC4. In HLSL shaders:
- Sampling a BC4 texture returns the value in the red component
(
r), with green and blue defaulting to zero and alpha defaulting to one. - No manual unpacking, bit-shifting, or multi-sample swizzling is required in the shader code.
- The texture cache benefits directly from the reduced 64-bit block size, maximizing cache hits during texture-heavy rendering passes such as deferred lighting or shadow mapping.
Support for Signed Data
In addition to standard unsigned textures (BC4_UNORM),
DirectX supports signed data through BC4_SNORM. This
variant maps single-channel values to the range
[-1.0, 1.0]. This makes BC4 suitable for displacement maps,
vector height offsets, or delta values that require negative numbers
without requiring runtime remapping logic in the shader.