: ${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
{
i=$1; shift
ia=$1; shift
- o=$1; shift; shift
- convert "$i" "$ia" -compose CopyOpacity -composite -type TrueColorMatte "$tmpdir/x.tga" && \
+ o=$1; shift; shift
+ convert "$i" "$ia" -auto-orient -compose CopyOpacity -composite -type TrueColorMatte "$tmpdir/x.tga" && \
pickdxta "$dds_tool" "$dds_sepalpha" "$tmpdir/x.tga" "$o" $1
}
{
i=$1; shift
ia=$1; shift
- o=$1; shift; shift
- convert "$i" "$ia" -compose CopyOpacity -composite -type TrueColorMatte "$tmpdir/x.tga" && \
+ o=$1; shift; shift
+ convert "$i" "$ia" -auto-orient -compose CopyOpacity -composite -type TrueColorMatte "$tmpdir/x.tga" && \
pickdxta "$dds_tool" "$dds_prealpha" "$tmpdir/x.tga" "$o" $1
}
ia=$1; shift
o=$1; shift
oa=$1; shift
- if convert "$i" TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then
+ if convert "$i" -auto-orient TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then
if [ "`stat -c %s "$i"`" -lt "`stat -c %s "$o"`" ]; then
cp "$i" "$o"
fi
else
return 1
fi
- if convert "$ia" TGA:- | cjpeg -targa -quality "$2" -optimize -sample 1x1,1x1,1x1 > "$oa"; then
+ if convert "$ia" -auto-orient TGA:- | cjpeg -targa -quality "$2" -optimize -sample 1x1,1x1,1x1 > "$oa"; then
if [ "`stat -c %s "$ia"`" -lt "`stat -c %s "$oa"`" ]; then
cp "$ia" "$oa"
fi
ia=$1; shift
o=$1; shift; shift
# this one MUST run
- convert "$i" "$ia" -compose CopyOpacity -composite -type TrueColorMatte "$tmpdir/x.png" && \
+ convert "$i" "$ia" -auto-orient -compose CopyOpacity -composite -type TrueColorMatte "$tmpdir/x.png" && \
cwebp $1 "$tmpdir/x.png" -o "$o"
}
{
i=$1; shift; shift
o=$1; shift; shift
- if convert "$i" TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then
+ if convert "$i" -auto-orient TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then
if [ "`stat -c %s "$i"`" -lt "`stat -c %s "$o"`" ]; then
cp "$i" "$o"
fi
{
i=$1; shift; shift
o=$1; shift; shift
- convert "$i" -type TrueColorMatte "$tmpdir/x.tga" && \
+ convert "$i" -auto-orient -type TrueColorMatte "$tmpdir/x.tga" && \
pickdxta "$dds_tool" "$dds_sepalpha" "$tmpdir/x.tga" "$o" $1
}
{
i=$1; shift; shift
o=$1; shift; shift
- convert "$i" -type TrueColorMatte "$tmpdir/x.tga" && \
+ convert "$i" -auto-orient -type TrueColorMatte "$tmpdir/x.tga" && \
pickdxta "$dds_tool" "$dds_prealpha" "$tmpdir/x.tga" "$o" $1
}
i=$1; shift; shift
o=$1; shift
oa=$1; shift
- if convert "$i" -alpha off TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then
+ if convert "$i" -auto-orient -alpha off TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then
:
else
return 1
fi
- if convert "$i" -alpha extract TGA:- | cjpeg -targa -quality "$2" -optimize -sample 1x1,1x1,1x1 > "$oa"; then
+ if convert "$i" -auto-orient -alpha extract TGA:- | cjpeg -targa -quality "$2" -optimize -sample 1x1,1x1,1x1 > "$oa"; then
:
else
return 1
{
i=$1; shift; shift
o=$1; shift; shift
- convert "$i" -type TrueColor "$tmpdir/x.tga" && \
+ convert "$i" -auto-orient -type TrueColor "$tmpdir/x.tga" && \
"$meprefix"compress-texture "$dds_tool" "$dds_noalpha" "$tmpdir/x.tga" "$o" $1
}
{
i=$1; shift; shift
o=$1; shift; shift
- if convert "$i" TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then
+ if convert "$i" -auto-orient TGA:- | cjpeg -targa -quality "$1" -optimize -sample 1x1,1x1,1x1 > "$o"; then
:
else
return 1
{
i=$1; shift; shift
o=$1; shift; shift
- convert "$i" "$tmpdir/x.png" && \
+ convert "$i" -auto-orient "$tmpdir/x.png" && \
cwebp $1 "$tmpdir/x.png" -o "$o"
}
{
i=$1; shift; shift
o=$1; shift; shift
- if convert "$i" -depth 16 RGBA:- | perl -e 'while(read STDIN, $_, 8) { substr($_, 6, 2) eq "\xFF\xFF" or exit 1; } exit 0;'; then
+ if convert "$i" -auto-orient -depth 16 RGBA:- | perl -e 'while(read STDIN, $_, 8) { substr($_, 6, 2) eq "\xFF\xFF" or exit 1; } exit 0;'; then
# no alpha
: > "$o"
else
;;
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