: ${jpeg_qual_rgb:=95}
: ${jpeg_qual_a:=99}
: ${do_dds:=true}
-: ${dds_flags:=}
+: ${dds_tool:=compressonator}
: ${do_ogg:=false}
: ${ogg_qual:=1}
+me=$0
+case "$me" in
+ */*)
+ meprefix=${me%/*}/
+ ;;
+ *)
+ meprefix=
+ ;;
+esac
+
tmpdir=`mktemp -d -t cached-converter.XXXXXX`
trap 'exit 1' INT
trap 'rm -rf "$tmpdir"' EXIT
else
rm -f "$tempfile1"
rm -f "$tempfile2"
- exit 1
+ exit 1
fi
}
ia=$1; shift
o=$1; shift; shift
convert "$i" "$ia" -compose CopyOpacity -composite "$tmpdir/x.png" && \
- nvcompress -alpha -bc3 $1 "$tmpdir/x.png" "$o"
+ "$meprefix"compress-texture "$dds_tool" dxt5 "$tmpdir/x.png" "$o" $1
}
reduce_jpeg2_jpeg2()
{
i=$1; shift; shift
o=$1; shift; shift
- nvcompress -alpha -bc3 $1 "$i" "$o"
+ "$meprefix"compress-texture "$dds_tool" dxt5 "$i" "$o" $1
}
reduce_rgba_jpeg2()
{
i=$1; shift; shift
o=$1; shift; shift
- nvcompress -bc1 $1 "$i" "$o"
+ "$meprefix"compress-texture "$dds_tool" dxt1 "$i" "$o" $1
}
reduce_rgb_jpeg()
--- /dev/null
+#!/bin/sh
+
+# usage: compress-texture tool compression in.png out.dds
+# example: compress-texture compressonator dxt1 foo.jpg foo.dds
+
+tool=$1; shift
+format=$1; shift
+src=$1; shift
+dst=$1; shift
+
+f=
+case "$tool" in
+ compressonator)
+ case "$format" in
+ dxt1) f="+fourCC DXT1" ;;
+ dxt3) f="+fourCC DXT3" ;;
+ dxt5) f="+fourCC DXT5" ;;
+ esac
+ echo ">> $f ($format)"
+ dir=`mktemp -d "$HOME/.wine/drive_c/compressonator.XXXXXX"`
+ dir_dos="C:/${dir##*/}"
+ ext=${src##*.}
+ cp "$src" "$dir/src.$ext"
+ wine "$HOME/.wine/drive_c/Program Files/AMD/The Compressonator 1.50/TheCompressonator.exe" -convert -mipmaps "$dir_dos/src.$ext" "$dir_dos/dst.dds" -codec DXTC.dll $f "$@"
+ mv "$dir/dst.dds" "$dst"
+ rm -rf "$dir"
+ ;;
+ nvcompress)
+ case "$format" in
+ dxt1) f="-bc1" ;;
+ dxt3) f="-alpha -bc3" ;;
+ dxt5) f="-alpha -bc5" ;;
+ esac
+ nvcompress $f "$@" "$src" "$dst"
+ ;;
+esac