]> git.xonotic.org Git - xonotic/xonotic.git/commitdiff
add a REALLY FUN FUN FUN texture randomizer script
authorRudolf Polzer <divverent@xonotic.org>
Sun, 4 Sep 2011 20:51:31 +0000 (22:51 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Sun, 4 Sep 2011 20:51:31 +0000 (22:51 +0200)
misc/tools/bsptool-shaderfun.sh [new file with mode: 0755]

diff --git a/misc/tools/bsptool-shaderfun.sh b/misc/tools/bsptool-shaderfun.sh
new file mode 100755 (executable)
index 0000000..b6b656d
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+# input: a .shader file
+# parameters: in and out .bsp file
+
+BSPTOOL="${0%/*}"/bsptool.pl
+LF="
+"
+
+in=$1
+out=$2
+
+shaders=`"$BSPTOOL" "$in" -S`
+
+newshaders=`cat | grep '^[^    {}]'`
+
+set --
+
+list=
+for shader in $shaders; do
+       if [ -z "$list" ]; then
+               echo >&2 "Filling list..."
+               list=`echo "$newshaders" | sort -R`$LF
+       fi
+       case "$shader" in
+               noshader|NULL|textures/common/*)
+                       ;;
+               *)
+                       item=${list%%$LF*}
+                       list=${list#*$LF}
+                       set -- "$@" "-S$shader=$item"
+                       ;;
+       esac
+done
+
+set -- "$BSPTOOL" "$in" "$@" -o"$out"
+"$@"