Just saw this beauty from some example code:

DXT3AlphaBlock compressDXT3Alpha(vec4 colors[16]) { DXT3AlphaBlock dxt3Alpha; unsigned int quantizedAlpha0 = quantize4(int(colors[0].w * 255.0 + .5)); unsigned int quantizedAlpha1 = quantize4(int(colors[1].w * 255.0 + .5)); unsigned int quantizedAlpha2 = quantize4(int(colors[2].w * 255.0 + .5)); unsigned int quantizedAlpha3 = quantize4(int(colors[3].w * 255.0 + .5)); unsigned int quantizedAlpha4 = quantize4(int(colors[4].w * 255.0 + .5)); unsigned int quantizedAlpha5 = quantize4(int(colors[5].w * 255.0 + .5)); unsigned int quantizedAlpha6 = quantize4(int(colors[6].w * 255.0 + .5)); unsigned int quantizedAlpha7 = quantize4(int(colors[7].w * 255.0 + .5)); dxt3Alpha.alphas[0] = quantizedAlpha0 << unsigned int(0) | quantizedAlpha1 << unsigned int(4) | quantizedAlpha2 << unsigned int(8) | quantizedAlpha3 << unsigned int(12) | quantizedAlpha4 << unsigned int(16) | quantizedAlpha5 << unsigned int(20) | quantizedAlpha6 << unsigned int(24) | quantizedAlpha7 << unsigned int(28); unsigned int quantizedAlpha8 = quantize4(int(colors[8].w * 255.0 + .5)); unsigned int quantizedAlpha9 = quantize4(int(colors[9].w * 255.0 + .5)); unsigned int quantizedAlpha10 = quantize4(int(colors[10].w * 255.0 + .5)); unsigned int quantizedAlpha11 = quantize4(int(colors[11].w * 255.0 + .5)); unsigned int quantizedAlpha12 = quantize4(int(colors[12].w * 255.0 + .5)); unsigned int quantizedAlpha13 = quantize4(int(colors[13].w * 255.0 + .5)); unsigned int quantizedAlpha14 = quantize4(int(colors[14].w * 255.0 + .5)); unsigned int quantizedAlpha15 = quantize4(int(colors[15].w * 255.0 + .5)); dxt3Alpha.alphas[1] = quantizedAlpha8 << unsigned int(0) | quantizedAlpha9 << unsigned int(4) | quantizedAlpha10 << unsigned int(8) | quantizedAlpha11 << unsigned int(12) | quantizedAlpha12 << unsigned int(16) | quantizedAlpha13 << unsigned int(20) | quantizedAlpha14 << unsigned int(24) | quantizedAlpha15 << unsigned int(28); return dxt3Alpha; }

What do you think?

-MIGI0027