]> de.git.xonotic.org Git - xonotic/xonotic-maps.pk3dir.git/blobdiff - scripts/shader-audit.sh
another recompile please, Y U no make good screenshots
[xonotic/xonotic-maps.pk3dir.git] / scripts / shader-audit.sh
index 0661537d1c84a17299c5e63a5ea0afa0598fbb46..80dd7d20e2ab29e1b35bb29b317d3b9083b476ed 100755 (executable)
@@ -93,7 +93,7 @@ use_texture()
                if [ "$3" = "shader" ]; then
                        return
                else
-                       err "shader $1 uses non-existing texture $2"
+                       err "$1 uses non-existing texture $2"
                fi
        fi
        textures_used="$textures_used$LF$2"
@@ -106,9 +106,9 @@ use_texture()
                                        '') # no dpoffsetmapping keyword
                                                getstats "../${2}_norm.tga" || getstats "../${2}_norm.png" || getstats "../${2}_norm.jpg"
                                                if [ "$min" -eq "$max" ]; then
-                                                       warn "shader $1 uses broken normalmap ${2}_norm.tga (add dpoffsetmapping none)"
+                                                       warn "$1 uses broken normalmap ${2}_norm.tga (add dpoffsetmapping none)"
                                                else
-                                                       err "shader $1 uses ${2}_norm.tga but lacks median (add dpoffsetmapping - 1 match8 $median)"
+                                                       err "$1 uses ${2}_norm.tga but lacks median (add dpoffsetmapping - 1 match8 $median)"
                                                fi
                                                ;;
                                        none) # offsetmapping turned off explicitly
@@ -116,9 +116,9 @@ use_texture()
                                        default) # offsetmapping keyword without bias
                                                getstats "../${2}_norm.tga"
                                                if [ "$min" -eq "$max" ]; then
-                                                       warn "shader $1 uses broken normalmap ${2}_norm.tga, maybe use dpoffsetmapping none?"
+                                                       warn "$1 uses broken normalmap ${2}_norm.tga, maybe use dpoffsetmapping none?"
                                                else
-                                                       err "shader $1 uses ${2}_norm.tga but lacks median (add to dpoffsetmapping: match8 $median)"
+                                                       err "$1 uses ${2}_norm.tga but lacks median (add to dpoffsetmapping: match8 $median)"
                                                fi
                                                ;;
                                        *) # offsetmapping keyword with bias
@@ -126,7 +126,7 @@ use_texture()
                                esac
                        else
                                if [ -n "$offsetmapping_match8" ]; then
-                                       warn "shader $1 specifies offsetmapping, but texture $2 does not have a normalmap"
+                                       warn "$1 specifies offsetmapping, but texture $2 does not have a normalmap"
                                fi
                        fi
                fi
@@ -152,7 +152,7 @@ use_texture()
                esac
        done
        if ! $ok; then
-               err "shader $1 is not allowed in this shader file (allowed: $allowed_prefixes, forbidden: $forbidden_prefixes)"
+               err "$1 is not allowed in this shader file (allowed: $allowed_prefixes, forbidden: $forbidden_prefixes)"
        fi
 
        case "$3" in
@@ -206,14 +206,14 @@ use_texture()
                        esac
                        ;;
                ## RULE: textures/map_FOO[_/]* must use textures/map_FOO[_/]*
-               textures/map_*/*)
+               textures/map_*/*|models/map_*/*)
                        pre=${1%%/map_*}
                        suf=${1#*/map_}
                        map=${suf%%[_/]*}
                        case "$2" in
                                "$pre"/map_$map[/_]*)
                                        ;;
-                               textures/map_*)
+                               textures/map_*|models/map_*)
                                        # protect one map's textures from the evil of other maps :P
                                        err "texture $2 of shader $1 is out of place, recommended file name is $pre/map_$map/*"
                                        ;;
@@ -234,8 +234,8 @@ use_texture()
                                        ;;
                        esac
                        ;;
-               ## RULE: textures/FOO/* must use textures/FOO/*, for FOO in decals, liquids_water, liquids_slime, liquids_lava
-               textures/decals/*|textures/liquids_*/*|textures/effects_*/*|textures/screens/*|textures/logos/*)
+               ## RULE: textures/FOO/* must use textures/FOO/*, for FOO in decals, liquids_water, liquids_slime, liquids_lava, alphamod
+               textures/decals/*|textures/liquids_*/*|textures/effects_*/*|textures/screens/*|textures/logos/*|textures/alphamod/*)
                        pre=`echo "$1" | cut -d / -f 1-2`
                        case "$2" in
                                "$pre"/*)
@@ -451,7 +451,7 @@ parse_shaderfile()
        case "$1" in
                ## RULE: map_FOO.shader may define tetxures/map_FOO_* and textures/map_FOO/*
                map_*)
-                       allowed_prefixes="textures/map_`echo "$1" | cut -d _ -f 2`_ textures/map_`echo "$1" | cut -d _ -f 2`/"
+                       allowed_prefixes="textures/map_`echo "$1" | cut -d _ -f 2`_ textures/map_`echo "$1" | cut -d _ -f 2`/ models/map_`echo "$1" | cut -d _ -f 2`_ models/map_`echo "$1" | cut -d _ -f 2`/"
                        forbidden_prefixes=
                        ;;
                ## RULE: skies_FOO.shader may define tetxures/skies/FOO and textures/skies/FOO_*
@@ -462,7 +462,7 @@ parse_shaderfile()
                ## RULE: model_*.shader may define models/*
                model_*)
                        allowed_prefixes="models/"
-                       forbidden_prefixes=
+                       forbidden_prefixes="models/map_"
                        ;;
                ## RULE: any other FOO.shader may define textures/FOO/*
                *)
@@ -499,13 +499,15 @@ for X in *.shader; do
 done
 rm -f "$t"
 
-textures_avail=`( cd ..; find textures/ -type f -not -name '*.sh' -not -name '*_norm.*' -not -name '*_glow.*' -not -name '*_gloss.*' -not -name '*_reflect.*' -not -name '*.xcf' ) | while IFS= read -r T; do normalize "$T"; done | sort -u`
+textures_avail=`( cd ..; find textures/ -type f -not -name '*.sh' -not -name '*_norm.*' -not -name '*_glow.*' -not -name '*_gloss.*' -not -name '*_reflect.*' -not -name '*.xcf' -not -name '*.txt' ) | while IFS= read -r T; do normalize "$T"; done | sort -u`
 textures_used=`echo "${textures_used#$LF}" | sort -u`
 
 echo "$textures_used$LF$textures_used$LF$textures_avail" | sort | uniq -u | while IFS= read -r L; do
        case "$L" in
                textures/radiant/*)
                        ;;
+               models/map_*/*)
+                       ;;
                textures/map_*/*)
                        ;;
                *)