+ jqual_rgb=$jpeg_qual_rgb
+ jqual_a=$jpeg_qual_a
+ webp_mode=lq
+
+ will_jpeg=$do_jpeg
+ will_webp=$do_webp
+ will_dds=$do_dds
+ will_ogg=$do_ogg
+ if ! $ogg_ogg; then
+ case "$f" in
+ *.ogg) will_ogg=false ;;
+ esac
+ fi
+ 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 ;;
+ ./textures/*) ;;
+ ./models/*) ;;
+ ./particles/*) ;;
+ ./progs/*) ;;
+ *)
+ # we can't DDS compress the 2D textures, sorry
+ # but JPEG is still fine
+ will_dds=false
+ ;;
+ 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
+ ./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