X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=misc%2Ftools%2Fcached-converter.sh;h=642edb108062a356c0986532e48246cd92337b05;hb=ed483a565b82d35595fc4f44d38cf61f66875400;hp=1c7051456ff69d1bbc4604b91e58d266a0fb3095;hpb=b7c48a7e7bf1c034e30031b521e1cc22c0df3f6e;p=xonotic%2Fxonotic.git diff --git a/misc/tools/cached-converter.sh b/misc/tools/cached-converter.sh index 1c705145..642edb10 100755 --- a/misc/tools/cached-converter.sh +++ b/misc/tools/cached-converter.sh @@ -13,6 +13,9 @@ set -e : ${ogg_qual:=1} : ${del_src:=false} : ${git_src_repo:=} +: ${dds_noalpha:=dxt1} +: ${dds_prealpha:=dxt4} +: ${dds_sepalpha:=dxt5} selfprofile_t0=`date +%s` selfprofile_step=init @@ -121,8 +124,8 @@ cached() [ -z "$outfile2" ] || tempfile2="${name2%/*}/new-${name2##*/}" if [ -f "$name1" ] && { [ -z "$outfile2" ] || [ -f "$name2" ]; }; then selfprofile convert_copyoutput - case "$outfile1" in */*) mkdir -p "${outfile1%/*}"; esac && { ln -vf "$name1" "$outfile1" || { rm -f "$outfile1" && cp "$name1" "$outfile1"; }; } - [ -z "$outfile2" ] || { case "$outfile2" in */*) mkdir -p "${outfile2%/*}"; esac && { ln -vf "$name2" "$outfile2" || { rm -f "$outfile2" && cp "$name2" "$outfile2"; }; }; } + case "$outfile1" in */*) mkdir -p "${outfile1%/*}"; esac && { ln -f "$name1" "$outfile1" 2>/dev/null || { rm -f "$outfile1" && cp "$name1" "$outfile1"; }; } + [ -z "$outfile2" ] || { case "$outfile2" in */*) mkdir -p "${outfile2%/*}"; esac && { ln -f "$name2" "$outfile2" 2>/dev/null || { rm -f "$outfile2" && cp "$name2" "$outfile2"; }; }; } conv=true elif selfprofile convert_makeoutput; "$method" "$infile1" "$infile2" "$tempfile1" "$tempfile2" "$@"; then mv "$tempfile1" "$name1" @@ -146,7 +149,7 @@ reduce_jpeg2_dds() ia=$1; shift o=$1; shift; shift convert "$i" "$ia" -compose CopyOpacity -composite "$tmpdir/x.tga" && \ - "$meprefix"compress-texture "$dds_tool" dxt5 "$tmpdir/x.tga" "$o" $1 + "$meprefix"compress-texture "$dds_tool" "$dds_sepalpha" "$tmpdir/x.tga" "$o" $1 } reduce_jpeg2_dds_premul() @@ -155,7 +158,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" dxt4 "$tmpdir/x.tga" "$o" $1 + "$meprefix"compress-texture "$dds_tool" "$dds_prealpha" "$tmpdir/x.tga" "$o" $1 } reduce_jpeg2_jpeg2() @@ -215,7 +218,7 @@ reduce_rgba_dds() i=$1; shift; shift o=$1; shift; shift convert "$i" "$tmpdir/x.tga" && \ - "$meprefix"compress-texture "$dds_tool" dxt5 "$tmpdir/x.tga" "$o" $1 + "$meprefix"compress-texture "$dds_tool" "$dds_sepalpha" "$tmpdir/x.tga" "$o" $1 } reduce_rgba_dds_premul() @@ -223,7 +226,7 @@ reduce_rgba_dds_premul() i=$1; shift; shift o=$1; shift; shift convert "$i" "$tmpdir/x.tga" && \ - "$meprefix"compress-texture "$dds_tool" dxt4 "$tmpdir/x.tga" "$o" $1 + "$meprefix"compress-texture "$dds_tool" "$dds_prealpha" "$tmpdir/x.tga" "$o" $1 } reduce_rgba_jpeg2() @@ -248,7 +251,7 @@ reduce_rgb_dds() i=$1; shift; shift o=$1; shift; shift convert "$i" "$tmpdir/x.tga" && \ - "$meprefix"compress-texture "$dds_tool" dxt1 "$tmpdir/x.tga" "$o" $1 + "$meprefix"compress-texture "$dds_tool" "$dds_noalpha" "$tmpdir/x.tga" "$o" $1 } reduce_rgb_jpeg() @@ -288,7 +291,9 @@ for F in "$@"; do will_jpeg=$do_jpeg will_dds=$do_dds + will_ogg=$do_ogg case "$f" in + ./sounds/misc/talk*.wav) will_ogg=false ;; # engine "feature" *_bump) will_dds=false ;; ./models/player/*) will_dds=false ;; ./models/sprites/*) will_dds=false ;; @@ -303,6 +308,20 @@ for F in "$@"; do ;; esac + # configure S2TC + case "$f" in + *_norm) + export S2TC_COLORDIST_MODE=NORMALMAP + export S2TC_RANDOM_COLORS=256 + export S2TC_REFINE_COLORS=LOOP + ;; + *) + export S2TC_COLORDIST_MODE=SRGB_MIXED + export S2TC_RANDOM_COLORS=64 + export S2TC_REFINE_COLORS=LOOP + ;; + esac + # for deluxemaps, lightmaps and normalmaps, enforce high jpeg quality (like on alpha channels) if [ "$jqual_a" -gt "$jqual_rgb" ]; then case "$f" in @@ -365,13 +384,13 @@ for F in "$@"; do rm -f "$F.hasalpha" ;; *.ogg) - cached "$do_ogg" reduce_ogg_ogg "$F" "" "$F" "" "$ogg_qual" + cached "$will_ogg" reduce_ogg_ogg "$F" "" "$F" "" "$ogg_qual" ;; ./sound/misc/null.wav) # never convert this one ;; *.wav) - cached "$do_ogg" reduce_wav_ogg "$F" "" "${f}.ogg" "" "$ogg_qual" + cached "$will_ogg" reduce_wav_ogg "$F" "" "${f}.ogg" "" "$ogg_qual" ;; esac selfprofile marktodelete