2
$\begingroup$

So i've a made a texture. I've saved the RGB one with BC7 compression, then added alpha channel[specular map] with varying levels of grayscale, and saved the file again as RGBA with BC7 compression. The resulting file has the same size as the one without alpha, yet it contain additional information -alpha channel. How it is possible? You can't have cake and eat cake as i understand, so are there any compromises made to ensure same size?

Im using photoshop with intel DDS plugin.

$\endgroup$
3
$\begingroup$

BC7 always effectively encodes 4 channels. That's part of the nature of the format. Turning on alpha means that the compressor will read and use the alpha value in your source image, but that's all.

All BC7 compressed images of a given dimension have the same size, since BC7 compresses each 4x4 group of texels into 128-bits. But that doesn't mean they have the same quality.

BC7 is an adaptive encoding format. While each block has a fixed size (both spatially and bit-wise), each block stores how many channels that block actually compresses and the way that they correlate with one another. The specifics are complex, but the general upside is that the compressor figures out on a per-block basis what manner of compression works best for a particular block. If the compressor can look at a block and see that the alpha for all texels is 1.0, then it can spend more bits of the 128 bits on the colors and fewer on the alpha.

As such, a texture "without alpha" is exactly like a texture with alpha where every texel has an alpha of 1. These blocks will spend the majority of their bits on the non-alpha parts of the texels, only wasting a few bits on a "mode" field that lets the decompressor know that the alpha is a constant 1.0.

This also means that, if your texture has a varying alpha, but parts of it have a constant alpha, BC7 can encode these constant alpha areas with fewer bits, so that more bits can be spent on improved color encoding.

So you shouldn't feel that there is a problem because the two compression switches came out with the same number of bytes.

| improve this answer | |
$\endgroup$
2
$\begingroup$

Here is an article about the BCn format: click me. It is written by Nathan Reed, who is quite active on this site. So he will probably pass by and might answer your question with more details, even though I think the article will explain everything you need to know.

The most relevant part for your question seems to be this section from the article:

BC stands for “block compression”, and the BCn formats all operate in terms of 4×4 blocks of pixels. All images are sliced up into these small blocks, and each block is self-contained—the data to decode it is all in one contiguous chunk in memory. Moreover, the size of each compressed block is fixed—either 8 or 16 bytes, depending on which BCn format is being used. This represents a 4:1 or 8:1 compression ratio, if the source image is in 8-bit RGBA format.

So as long as your pixel count does not change, the size of the texture does not change either. However, the more channels you use (only 3 and 4 are supported by BC7 according to the Microsoft documentation), the less information you can store per color channel in a block. This means, that you lose more information due to compression when using RGBA instead of RGB.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.