+ # 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.
+ export CRUNCH_TEXTYPEFLAGS='-gamma 1.0 -renormalize -rtopmip -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.
+ export CRUNCH_TEXTYPEFLAGS='-gamma 1.0 -renormalize -rtopmip -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
+
+ # for deluxemaps, lightmaps and normalmaps, enforce high jpeg quality (like on alpha channels)
+ if [ "$jqual_a" -gt "$jqual_rgb" ]; then
+ case "$f" in
+ ./maps/*/lm_[0-9][0-9][0-9][13579]) # deluxemap
+ jqual_rgb=$jqual_a
+ webp_mode=hq
+ ;;
+ ./maps/*/lm_[0-9][0-9][0-9][02468]) # lightmap
+ jqual_rgb=$jqual_a
+ webp_mode=hq
+ ;;
+ *_norm) # normalmap
+ jqual_rgb=$jqual_a
+ webp_mode=hq
+ ;;
+ 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
+ else
+ will_jpeg=true
+ fi
+ fi
+ if $do_webp_if_not_dds; then
+ if $will_dds; then
+ will_webp=false
+ else
+ will_webp=true
+ fi
+ fi
+ selfprofile startconvert