]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - misc/tools/cached-converter.sh
Oops, actually select OS X ;)
[xonotic/xonotic.git] / misc / tools / cached-converter.sh
index 84f3480db11917b8066c8ad603303a9195b2a3ed..a538c70981f6ec0c7517f4f3559d3125dda0efa7 100755 (executable)
@@ -21,8 +21,8 @@ set -e
 : ${del_src:=false}
 : ${git_src_repo:=}
 : ${dds_noalpha:=dxt1}
-: ${dds_prealpha:=dxt2 dxt4}
-: ${dds_sepalpha:=dxt3 dxt5}
+: ${dds_prealpha:=dxt1 dxt2 dxt4}
+: ${dds_sepalpha:=dxt1 dxt3 dxt5}
 
 selfprofile_t0=`date +%s`
 selfprofile_step=init
@@ -209,7 +209,7 @@ reduce_jpeg2_dds()
 {
        i=$1; shift
        ia=$1; shift
-       o=$1; shift; shift 
+       o=$1; shift; shift
        convert "$i" "$ia" -compose CopyOpacity -composite -type TrueColorMatte "$tmpdir/x.tga" && \
        pickdxta "$dds_tool" "$dds_sepalpha" "$tmpdir/x.tga" "$o" $1
 }
@@ -218,7 +218,7 @@ reduce_jpeg2_dds_premul()
 {
        i=$1; shift
        ia=$1; shift
-       o=$1; shift; shift 
+       o=$1; shift; shift
        convert "$i" "$ia" -compose CopyOpacity -composite -type TrueColorMatte "$tmpdir/x.tga" && \
        pickdxta "$dds_tool" "$dds_prealpha" "$tmpdir/x.tga" "$o" $1
 }
@@ -375,13 +375,13 @@ for F in "$@"; do
        will_dds=$do_dds
        will_ogg=$do_ogg
        if ! $ogg_ogg; then
-               case "$f" in
+               case "$F" in
                        *.ogg) will_ogg=false ;;
                esac
        fi
-       case "$f" in
+       case "$F" in
                ./sound/misc/talk*.wav) will_ogg=false ;; # engine "feature"
-               *_bump) will_dds=false ;;
+               *_bump.*) will_dds=false ;;
                ./models/player/*) will_dds=false ;;
                ./models/sprites/*) will_dds=false ;;
                ./models/*) ;;
@@ -396,17 +396,36 @@ for F in "$@"; do
                        ;;
        esac
 
-       # configure S2TC
+       # Specific hacks for normalmaps.
        case "$f" in
+               ./maps/*/lm_[0-9][0-9][0-9][13579]) # deluxemap
+                       export S2TC_COLORDIST_MODE=NORMALMAP
+                       export S2TC_RANDOM_COLORS=256
+                       export S2TC_REFINE_COLORS=LOOP
+                       export S2TC_DITHER_MODE=NONE
+                       # Engine ignores alpha channel on these, so we can use the DXT1 black encoding.
+                       # Not that that color should happen very often on a deluxemap, but who knows.
+                       # NOT renormalizing, as DP does its own renormalization anyway in the GLSL shader
+                       # and crunch's renormalizing looks like it can cause banding artifacts.
+                       export CRUNCH_TEXTYPEFLAGS='-gamma 1.0 -uniformMetrics -usetransparentindicesforblack'
+                       ;;
                *_norm)
                        export S2TC_COLORDIST_MODE=NORMALMAP
                        export S2TC_RANDOM_COLORS=256
                        export S2TC_REFINE_COLORS=LOOP
+                       export S2TC_DITHER_MODE=NONE
+                       # Alpha channel here means height.
+                       # NOT renormalizing, as DP does its own renormalization anyway in the GLSL shader
+                       # and crunch's renormalizing looks like it can cause banding artifacts.
+                       export CRUNCH_TEXTYPEFLAGS='-gamma 1.0 -uniformMetrics'
                        ;;
                *)
                        export S2TC_COLORDIST_MODE=SRGB_MIXED
                        export S2TC_RANDOM_COLORS=64
                        export S2TC_REFINE_COLORS=LOOP
+                       export S2TC_DITHER_MODE=FLOYDSTEINBERG
+                       # Color channel-like images - consider as sRGB.
+                       export CRUNCH_TEXTYPEFLAGS='-gamma 2.2'
                        ;;
        esac