X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=misc%2Ftools%2Fcompress-texture;h=5141b92d04a0da6ec0f1aff748190114e48a12ad;hb=d44702bd4be320013f249cc62e8b0ed2161593e5;hp=36aa0281cbb85a3c153890c6007508649a8bb93f;hpb=0e918e479f02465659a8863aec44d1fbb3151ae0;p=xonotic%2Fxonotic.git diff --git a/misc/tools/compress-texture b/misc/tools/compress-texture index 36aa0281..5141b92d 100755 --- a/misc/tools/compress-texture +++ b/misc/tools/compress-texture @@ -10,11 +10,25 @@ 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 + case "$format" in + dxt2) + fourcchack=DXT2 + format=dxt2 + ;; + dxt4) + fourcchack=DXT4 + format=dxt4 + ;; + esac ;; *) case "$format" in @@ -29,6 +43,13 @@ case "$tool" in esac ;; esac + +if [ -n "$fourcchack" ]; then + fourcchack_dir=`mktemp -d` + convert "$src" -fx "u*u.a" "$fourcchack_dir/src.$ext" + src="$fourcchack_dir/src.$ext" +fi + case "$tool" in compressonator-dxtc|compressonator-atic) case "$tool" in @@ -44,7 +65,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 :( @@ -65,9 +85,18 @@ 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 $f "$@" -i "$src" -o "$dst" + ;; esac if [ -n "$fourcchack" ]; then # use dd to hack in the right FOURCC - echo -n "$fourcchack" | dd of="$dst" bs=1 count=4 seek=84 + echo -n "$fourcchack" | dd of="$dst" bs=1 count=4 seek=84 conv=notrunc + rm -rf "$fourcchack_dir" fi