3 # usage: compress-texture tool compression in.png out.dds
4 # example: compress-texture compressonator dxt1 foo.jpg foo.dds
19 # we still have to preprocess the image to premultiply alpha, as it seems
45 if [ -n "$fourcchack" ]; then
46 fourcchack_dir=`mktemp -d`
47 convert "$src" -fx "u*u.a" "$fourcchack_dir/src.$ext"
48 src="$fourcchack_dir/src.$ext"
52 compressonator-dxtc|compressonator-atic)
54 *-dxtc) c="-codec DXTC.dll" ;;
55 *-atic) c="-codec ATICompressor.dll" ;;
58 dxt1) f="+fourCC DXT1" ;;
59 dxt2) f="+fourCC DXT2" ;;
60 dxt3) f="+fourCC DXT3" ;;
61 dxt4) f="+fourCC DXT4" ;;
62 dxt5) f="+fourCC DXT5" ;;
64 dir=`mktemp -d "$HOME/.wine/drive_c/compressonator.XXXXXX"`
65 dir_dos="C:/${dir##*/}"
67 cp "$src" "$dir/src.$ext"
69 # compressonator and wine suck, so we sometimes have to retry :(
70 for retry in 1 2 3 4 5; do
71 wine "c:/Program Files/AMD/The Compressonator 1.50/TheCompressonator.exe" -convert -mipmaps "$dir_dos/src.$ext" "$dir_dos/dst.dds" $c $f "$@" -mipper BoxFilter.dll
72 if mv "$dir/dst.dds" "$dst"; then
82 dxt3) f="-alpha -bc3" ;;
83 dxt5) f="-alpha -bc5" ;;
85 nvcompress $f "$@" "$src" "$dst"
89 if [ -n "$fourcchack" ]; then
90 # use dd to hack in the right FOURCC
91 echo -n "$fourcchack" | dd of="$dst" bs=1 count=4 seek=84
92 rm -rf "$fourcchack_dir"