7 echo "Usage: $1 directory shader.template"
15 exec 3>"scripts/$1.shader"
18 find "textures/$1" -type f -path "textures/*/*/*.*" -not -name '*_norm.*' -not -name '*_glow.*' -not -name '*_gloss.*' -not -name '*_reflect.*' -not -name '*.xcf' | while IFS= read -r F; do
25 shaderString="$template"
43 shaderHead="$shaderHead surfaceparm trans\n surfaceparm water\n qer_trans 20\n"
48 shaderHead="$shaderHead surfaceparm trans\n surfaceparm slime\n qer_trans 20\n"
53 shaderHead="$shaderHead surfaceparm trans\n surfaceparm lava\n qer_trans 20\n"
57 shaderHead="$shaderHead surfaceparm trans\n"
58 diffuseExtra="$diffuseExtra blendfunc add\n"
61 bounceScale=`echo "$bounceScale + 0.25" | bc -l`
62 shaderHead="$shaderHead surfaceparm metalsteps\n"
69 bounceScale=`echo "$bounceScale + 0.25" | bc -l`
70 shaderHead="$shaderHead surfaceparm trans\n"
71 diffuseExtra="$diffuseExtra blendfunc blend\n"
78 bounceScale=`echo "$bounceScale + 0.25" | bc -l`
82 *dirt*|*terrain*|*old*)
83 bounceScale=`echo "$bounceScale - 0.25" | bc -l`
84 shaderHead="$shaderHead surfaceparm dust\n"
89 if [ -f "$F""_gloss.tga" ] || [ -f "$F""_gloss.jpg" ] || [ -f "$F""_gloss.png" ]; then
90 bounceScale=`echo "$bounceScale - 0.25" | bc -l`
93 if [ -f "$F""_qei.tga" ] || [ -f "$F""_qei.jpg" ] || [ -f "$F""_qei.png" ]; then
99 if ! $noLightmap; then
100 shaderTail=" {\n map \$lightmap\n rgbGen identity\n tcGen lightmap\n blendfunc filter\n }"
102 case "$bounceScale" in
106 shaderHead="$shaderHead q3map_bouncescale $bounceScale\n"
110 shaderName="`echo "$F" | cut -d / -f 1-2`/`echo "$F" | cut -d / -f 3`-`echo "$F" | cut -d / -f 4`"
111 echo "$shaderString$LF$LF" | sed -e "
112 s,%shader_name%,$shaderName,g;
113 s,%qei_name%,$shaderQUI,g;
114 s,%shader_head%,$shaderHead,g;
115 s,%diffuse_map%,$shaderDiffuse,g;
116 s,%diffuse_map_extra%,$diffuseExtra,g;
117 s,%shader_tail%,$shaderTail,g;