Beispiel #1
0
        static void CompressAlphaDxt3(byte[] rgba, int mask, ref byte[] block, int offset)
        {
            // quantise and pack the alpha values pairwise
            for (int i = 0; i < 8; ++i)
            {
                // quantise down to 4 bits
                float alpha1 = (float)rgba[8 * i + 3] * (15.0f / 255.0f);
                float alpha2 = (float)rgba[8 * i + 7] * (15.0f / 255.0f);
                int   quant1 = ColourBlock.FloatToInt(alpha1, 15);
                int   quant2 = ColourBlock.FloatToInt(alpha2, 15);

                // set alpha to zero where masked
                int bit1 = 1 << (2 * i);
                int bit2 = 1 << (2 * i + 1);
                if ((mask & bit1) == 0)
                {
                    quant1 = 0;
                }
                if ((mask & bit2) == 0)
                {
                    quant2 = 0;
                }

                // pack into the byte
                block[i + offset] = (byte)(quant1 | (quant2 << 4));
            }
        }
Beispiel #2
0
        public SingleColourFit(ColourSet colours, SquishFlags flags)
            : base(colours, flags)
        {
            // grab the single colour
            Vector3[] values = m_colours.Points;
            m_colour[0] = (byte)ColourBlock.FloatToInt(255.0f * values[0].X, 255);
            m_colour[1] = (byte)ColourBlock.FloatToInt(255.0f * values[0].Y, 255);
            m_colour[2] = (byte)ColourBlock.FloatToInt(255.0f * values[0].Z, 255);

            // initialise the best error
            m_besterror = int.MaxValue;
        }