From f825b2805174bbbad317ca31179b2cd0de69e8e9 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Tue, 19 Mar 2013 11:58:21 -0400 Subject: [PATCH] Single color partition with alpha bugfix. When we detect that a partition has a single color in each subset, we can generate almost an exact representation of this value for most compression modes. However, when we were doing this subset matching, we were ignoring the error introduced by modes that had completely opaque representations against data that had transparent pixels. This bug fix essentially includes this error in our "best fit" calculations and makes everything work out for the better. --- BPTCEncoder/src/BC7Compressor.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BPTCEncoder/src/BC7Compressor.cpp b/BPTCEncoder/src/BC7Compressor.cpp index 1ca2538..cd1bf32 100755 --- a/BPTCEncoder/src/BC7Compressor.cpp +++ b/BPTCEncoder/src/BC7Compressor.cpp @@ -362,9 +362,12 @@ double BC7CompressionMode::CompressSingleColor(const RGBAVector &p, RGBAVector & const uint8 val = (pixel >> (ci * 8)) & 0xFF; int nBits = ci == 3? GetAlphaChannelPrecision() : m_Attributes->colorChannelPrecision; - // If we don't handle this channel, then we don't need to - // worry about how well we interpolate. - if(nBits == 0) { bestValI[ci] = bestValJ[ci] = 0xFF; continue; } + // If we don't handle this channel, then it must be the full value (alpha) + if(nBits == 0) { + bestValI[ci] = bestValJ[ci] = 0xFF; + dist = std::max(dist, (uint32)((uint8)0xFF - val)); + continue; + } const int nPossVals = (1 << nBits); int possValsH[256];