]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - misc/tools/cached-converter.sh
instead, exclude background_l2 from that hashing stuff
[xonotic/xonotic.git] / misc / tools / cached-converter.sh
index 8827a50f9a5a3ae89b7ba51d43ea1785aa0424e3..06433d0856783deb4e1863eb87063e21d84fef8b 100755 (executable)
@@ -49,7 +49,15 @@ cached()
        if [ x"$infile1/../$infile2" = x"$lastinfiles" ]; then
                sum=$lastinfileshash
        else
-               if [ -n "$git_src_repo" ]; then
+               evil=false
+               for infile in "$infile1" "$infile2"; do
+                       case "$infile" in
+                               */background_l2.tga)
+                                       evil=true
+                                       ;;
+                       esac
+               done
+               if [ -n "$git_src_repo" ] && ! $evil; then
                        sum=`( cd "$git_src_repo"; git rev-parse --revs-only HEAD:"${infile1#./}" | grep . ) || git hash-object "$infile1"`
                        if [ -n "$infile2" ]; then
                                sum=$sum`( cd "$git_src_repo"; git rev-parse --revs-only HEAD:"${infile2#./}" | grep . ) || git hash-object "$infile2"`
@@ -93,6 +101,15 @@ reduce_jpeg2_dds()
        "$meprefix"compress-texture "$dds_tool" dxt5 "$tmpdir/x.tga" "$o" $1
 }
 
+reduce_jpeg2_dds_premul()
+{
+       i=$1; shift
+       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
+}
+
 reduce_jpeg2_jpeg2()
 {
        i=$1; shift
@@ -153,6 +170,14 @@ reduce_rgba_dds()
        "$meprefix"compress-texture "$dds_tool" dxt5 "$tmpdir/x.tga" "$o" $1
 }
 
+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
+}
+
 reduce_rgba_jpeg2()
 {
        i=$1; shift; shift
@@ -244,6 +269,13 @@ for F in "$@"; do
                esac
        fi
 
+       pm=
+       case "$f" in
+               ./particles/particlefont) # particlefont uses premultiplied alpha
+                       pm=_premul
+                       ;;
+       esac
+
        if $do_jpeg_if_not_dds; then
                if $will_dds; then
                        will_jpeg=false
@@ -264,22 +296,22 @@ for F in "$@"; do
                        ;;
                *.jpg)
                        if [ -f "${f}_alpha.jpg" ]; then
-                               cached "$will_dds"  reduce_jpeg2_dds   "$F" "${f}_alpha.jpg" "dds/${f}.dds" ""               "$dds_flags"
-                               cached "$will_jpeg" reduce_jpeg2_jpeg2 "$F" "${f}_alpha.jpg" "$F"           "${f}_alpha.jpg" "$jqual_rgb" "$jqual_a"
+                               cached "$will_dds"  reduce_jpeg2_dds$pm "$F" "${f}_alpha.jpg" "dds/${f}.dds" ""               "$dds_flags"
+                               cached "$will_jpeg" reduce_jpeg2_jpeg2  "$F" "${f}_alpha.jpg" "$F"           "${f}_alpha.jpg" "$jqual_rgb" "$jqual_a"
                        else                                   
-                               cached "$will_dds"  reduce_rgb_dds     "$F" ""               "dds/${f}.dds" ""               "$dds_flags"
-                               cached "$will_jpeg" reduce_jpeg_jpeg   "$F" ""               "$F"           ""               "$jqual_rgb"
+                               cached "$will_dds"  reduce_rgb_dds      "$F" ""               "dds/${f}.dds" ""               "$dds_flags"
+                               cached "$will_jpeg" reduce_jpeg_jpeg    "$F" ""               "$F"           ""               "$jqual_rgb"
                        fi
                        ;;
                *.png|*.tga)
                        cached true has_alpha "$F" "" "$F.hasalpha" ""
                        conv=false
                        if [ -s "$F.hasalpha" ]; then
-                               cached "$will_dds"  reduce_rgba_dds    "$F" ""               "dds/${f}.dds" ""               "$dds_flags"
-                               cached "$will_jpeg" reduce_rgba_jpeg2  "$F" ""               "${f}.jpg"     "${f}_alpha.jpg" "$jqual_rgb" "$jqual_a"
+                               cached "$will_dds"  reduce_rgba_dds$pm  "$F" ""               "dds/${f}.dds" ""               "$dds_flags"
+                               cached "$will_jpeg" reduce_rgba_jpeg2   "$F" ""               "${f}.jpg"     "${f}_alpha.jpg" "$jqual_rgb" "$jqual_a"
                        else                                                             
-                               cached "$will_dds"  reduce_rgb_dds     "$F" ""               "dds/${f}.dds" ""               "$dds_flags"
-                               cached "$will_jpeg" reduce_rgb_jpeg    "$F" ""               "${f}.jpg"     ""               "$jqual_rgb"
+                               cached "$will_dds"  reduce_rgb_dds      "$F" ""               "dds/${f}.dds" ""               "$dds_flags"
+                               cached "$will_jpeg" reduce_rgb_jpeg     "$F" ""               "${f}.jpg"     ""               "$jqual_rgb"
                        fi
                        rm -f "$F.hasalpha"
                        ;;