X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=misc%2Ftools%2Fcompress-texture;h=9d4fcc135eea9150de0b91996a017a2490e4dd53;hb=ed19d6fdc6a4de2b663a95fcd399fe0d335d68d8;hp=1c488b09503ec7603a2fd7bb6fecdda6ee156608;hpb=a780c8749a1364dbd6151e61fbe1a53e21ec5c56;p=xonotic%2Fxonotic.git diff --git a/misc/tools/compress-texture b/misc/tools/compress-texture index 1c488b09..9d4fcc13 100755 --- a/misc/tools/compress-texture +++ b/misc/tools/compress-texture @@ -10,13 +10,15 @@ format=$1; shift src=$1; shift dst=$1; shift +ext=${src##*.} + c= f= fourcchack= case "$tool" in - compressonator-dxtc) - # we still have to preprocess the image to premultiply alpha, as it seems + compressonator-dxtc|crunch) + # We still have to preprocess the image to premultiply alpha, as it seems case "$format" in dxt2) fourcchack=DXT2 @@ -28,7 +30,8 @@ case "$tool" in ;; esac ;; - *) + compressonator-atic|nvcompress|s2tc) + # These tools don't support DXT2/4 at all. case "$format" in dxt2) fourcchack=DXT2 @@ -40,11 +43,14 @@ case "$tool" in ;; esac ;; + *) + echo >&2 "Please figure out the DXT2/DXT4 story for $tool." + ;; esac if [ -n "$fourcchack" ]; then fourcchack_dir=`mktemp -d` - convert "$src" -fx "u*u.a" "$fourcchack_dir/src.$ext" + convert "$src" -auto-orient -fx "u*u.a" -type TrueColorMatte "$fourcchack_dir/src.$ext" src="$fourcchack_dir/src.$ext" fi @@ -63,7 +69,6 @@ case "$tool" in esac dir=`mktemp -d "$HOME/.wine/drive_c/compressonator.XXXXXX"` dir_dos="C:/${dir##*/}" - ext=${src##*.} cp "$src" "$dir/src.$ext" # compressonator and wine suck, so we sometimes have to retry :( @@ -84,6 +89,24 @@ case "$tool" in esac nvcompress $f "$@" "$src" "$dst" ;; + s2tc) + case "$format" in + dxt1) f="-t DXT1" ;; + dxt3) f="-t DXT3" ;; + dxt5) f="-t DXT5" ;; + esac + s2tc_compress $f "$@" -i "$src" -o "$dst" + ;; + crunch) + case "$format" in + dxt1) f="-DXT1" ;; + dxt2) f="-DXT2" ;; + dxt3) f="-DXT3" ;; + dxt4) f="-DXT4" ;; + dxt5) f="-DXT5" ;; + esac + crunch $f "$@" -noprogress -nostats -quality 255 -mipMode Generate -dxtQuality uber $CRUNCH_TEXTYPEFLAGS -file "$src" -out "$dst" + ;; esac if [ -n "$fourcchack" ]; then