From: Rudolf Polzer Date: Sat, 16 Jul 2011 10:15:57 +0000 (+0200) Subject: when compressing textures, check whether DXT3 or DXT5 is better, and use that (slower... X-Git-Tag: xonotic-v0.5.0~54 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=37884cfdbffeea150f3a8f72bc37b1e9d2541584;p=xonotic%2Fxonotic.git when compressing textures, check whether DXT3 or DXT5 is better, and use that (slower, better) --- diff --git a/misc/tools/cached-converter.sh b/misc/tools/cached-converter.sh index 642edb10..f1e535e6 100755 --- a/misc/tools/cached-converter.sh +++ b/misc/tools/cached-converter.sh @@ -14,8 +14,8 @@ set -e : ${del_src:=false} : ${git_src_repo:=} : ${dds_noalpha:=dxt1} -: ${dds_prealpha:=dxt4} -: ${dds_sepalpha:=dxt5} +: ${dds_prealpha:=dxt2 dxt4} +: ${dds_sepalpha:=dxt3 dxt5} selfprofile_t0=`date +%s` selfprofile_step=init @@ -143,13 +143,48 @@ cached() selfprofile convert_finished } +pickdxta() +{ + pd_t=$1; shift + pd_d=$1; shift + pd_i=$1; shift + pd_o=$1; shift + for pd_dd in $pd_d; do + if [ -f "$pd_o".dds ]; then + "$meprefix"compress-texture "$pd_t" "$pd_dd" "$pd_i" "$pd_o".tmp.dds "$@" + pd_psnr_tmp=`compare -channel alpha -metric PSNR "$pd_i" "$pd_o".tmp.dds NULL:` + echo >&2 "$pd_dd: $pd_psnr_tmp dB" + pd_psnr_diff=`echo "($pd_psnr_tmp) - ($pd_psnr)" | bc -l` + case "$pd_psnr_diff" in + -*|0) + # tmp is smaller or equal + # smaller PSNR is worse + # no action + ;; + *) + # tmp is larger + # larger PSNR is better + pd_psnr=$pd_psnr_tmp + mv "$pd_o".tmp.dds "$pd_o" + echo >&2 "PICKED (better)" + ;; + esac + else + "$meprefix"compress-texture "$pd_t" "$pd_dd" "$pd_i" "$pd_o" "$@" + pd_psnr=`compare -channel alpha -metric PSNR "$pd_i" "$pd_o" NULL:` + echo >&2 "$pd_dd: $pd_psnr dB" + echo >&2 "PICKED (first)" + fi + done +} + reduce_jpeg2_dds() { i=$1; shift ia=$1; shift o=$1; shift; shift convert "$i" "$ia" -compose CopyOpacity -composite "$tmpdir/x.tga" && \ - "$meprefix"compress-texture "$dds_tool" "$dds_sepalpha" "$tmpdir/x.tga" "$o" $1 + pickdxta "$dds_tool" "$dds_sepalpha" "$tmpdir/x.tga" "$o" $1 } reduce_jpeg2_dds_premul() @@ -158,7 +193,7 @@ reduce_jpeg2_dds_premul() ia=$1; shift o=$1; shift; shift convert "$i" "$ia" -compose CopyOpacity -composite "$tmpdir/x.tga" && \ - "$meprefix"compress-texture "$dds_tool" "$dds_prealpha" "$tmpdir/x.tga" "$o" $1 + pickdxta "$dds_tool" "$dds_prealpha" "$tmpdir/x.tga" "$o" $1 } reduce_jpeg2_jpeg2() @@ -218,7 +253,7 @@ reduce_rgba_dds() i=$1; shift; shift o=$1; shift; shift convert "$i" "$tmpdir/x.tga" && \ - "$meprefix"compress-texture "$dds_tool" "$dds_sepalpha" "$tmpdir/x.tga" "$o" $1 + pickdxta "$dds_tool" "$dds_sepalpha" "$tmpdir/x.tga" "$o" $1 } reduce_rgba_dds_premul() @@ -226,7 +261,7 @@ reduce_rgba_dds_premul() i=$1; shift; shift o=$1; shift; shift convert "$i" "$tmpdir/x.tga" && \ - "$meprefix"compress-texture "$dds_tool" "$dds_prealpha" "$tmpdir/x.tga" "$o" $1 + pickdxta "$dds_tool" "$dds_prealpha" "$tmpdir/x.tga" "$o" $1 } reduce_rgba_jpeg2()