7 echo "Usage: from xonotic-maps.pk3dir directory, copy and edit shader.template, then"
8 echo " $0 texturepackname myshader.template"
16 exec 3>"scripts/$1.shader"
19 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
26 shaderString="$template"
44 shaderHead="$shaderHead surfaceparm trans\n surfaceparm water\n qer_trans 20\n"
49 shaderHead="$shaderHead surfaceparm trans\n surfaceparm slime\n qer_trans 20\n"
54 shaderHead="$shaderHead surfaceparm trans\n surfaceparm lava\n qer_trans 20\n"
58 shaderHead="$shaderHead surfaceparm trans\n"
59 diffuseExtra="$diffuseExtra blendfunc add\n"
62 bounceScale=`echo "$bounceScale + 0.25" | bc -l`
63 shaderHead="$shaderHead surfaceparm metalsteps\n"
70 bounceScale=`echo "$bounceScale + 0.25" | bc -l`
71 shaderHead="$shaderHead surfaceparm trans\n"
72 diffuseExtra="$diffuseExtra blendfunc blend\n"
79 bounceScale=`echo "$bounceScale + 0.25" | bc -l`
83 *dirt*|*terrain*|*old*)
84 bounceScale=`echo "$bounceScale - 0.25" | bc -l`
85 shaderHead="$shaderHead surfaceparm dust\n"
90 if [ -f "$F""_gloss.tga" ] || [ -f "$F""_gloss.jpg" ] || [ -f "$F""_gloss.png" ]; then
91 bounceScale=`echo "$bounceScale - 0.25" | bc -l`
94 if [ -f "$F""_qei.tga" ] || [ -f "$F""_qei.jpg" ] || [ -f "$F""_qei.png" ]; then
100 if ! $noLightmap; then
101 shaderTail=" {\n map \$lightmap\n rgbGen identity\n tcGen lightmap\n blendfunc filter\n }"
103 case "$bounceScale" in
107 shaderHead="$shaderHead q3map_bouncescale $bounceScale\n"
111 shaderName="`echo "$F" | cut -d / -f 1-2`/`echo "$F" | cut -d / -f 3`-`echo "$F" | cut -d / -f 4`"
112 echo "$shaderString$LF$LF" | sed -e "
113 s,%shader_name%,$shaderName,g;
114 s,%qei_name%,$shaderQUI,g;
115 s,%shader_head%,$shaderHead,g;
116 s,%diffuse_map%,$shaderDiffuse,g;
117 s,%diffuse_map_extra%,$diffuseExtra,g;
118 s,%shader_tail%,$shaderTail,g;