» Sun May 05, 2013 6:49 am
I am not surprised. And I would be interested trying this tool. Do you know if it's available in any form nowadays? (What was its name?)
Here's why I am not surprised (and some people will already understand this, for example, if they had carefully read throttlekitty's references):
DXT compression handles colors by picking two colors, which are expressed using 5:6:5 bits (5 bits for red, 6 bits for green, 5 bits for blue). And then it uses two bits for each pixel -- for picking a color defined between the two reference colors. [And there's that sneaky little stunt that DXT1 uses for 1-bit alpha, which depends on the order of the two reference colors.] Anyways, this means that the maximum resolution under ideal circumstances for DXT compression is 7 bits for red, 8 bits for green and 7 bits for blue. And, this means that the worst case resolution is 2 bits for red, 2 bits for green and 2 bits for blue. Sort of...
Here's the trick, though: you can pick different reference colors to try to make the colors available from the two bits that specify each pixel "better fit" your image. As a "dumb simple first approximation" you can try all 4 billion possibilities of reference color combinations and measure the amount of error you would get by encoding the 16 pixels of the patch, and then pick the combination that produces the least error. But that's dumb, because no one should have to wait that long to save a file. Anyways, a "good compressor" has some opportunities for cleverness here. (The simple approach would be: find the brightest and dimmest color values, use them for the reference colors, then pick the best match for each pixel -- but what if you could get a better match for most of the colors by picking bounds that are farther apart, or closer together?)
(And there are different kinds of goodness -- a compressor for dxt textures that will be renormalized for use in normal maps would be totally different from one which is designed for imagery that a person will be looking at.)
Here's another trick: even though only 5 or 6 bits of color are specified, the colors are specified to 8 bit accuracy by taking the most significant bits of each color element and using them to fill in for the "missing bits". In other words the five bit color numbers look like this: (0, 8, 16, 24, 33, 41, 49, 57, 66, 74, 82, 90, 99, 107, 115, 123, 132, 140, 148, 156, 165, 173, 181, 189, 198, 206, 214, 222, 231, 239, 247 and 255). So if the compressor was assuming that the colors were evenly distributed it will sometimes be doing the wrong thing.
And here's another trick, and perhaps the most obvious (but still possible to get wrong). If you think of colors ranging from 0..1, the "1" corresponds to 255 and not 256 -- if the compressor is coded with the assumption that 256, 256, 256 corresponds to white that could be bad. (I do not know of any compressors which make this mistake -- and it seems extremely obvious -- but I think it could be an easy mistake to make if someone is trying to write "efficient code". Personally, though, I have made dumber mistakes when I have written programs, and this one would not be fatal, so it could easily get into released code.)
Anyways, I am not surprised to hear that some dxt compression algorithms do better than others.