Search the Community
Showing results for tags 'shell'.
-
I created this script for personal use, but thought it would be of enough interest to share here. I'm in the process of porting a few texture packs into TDM from Xonotic... each texture containing a diffuse / normal / specular map, as well as optionally a glow / reflection map. Obviously I don't want to have to manually create the same material for every texture, so I made a script to do it for me! Usage: Save this as a .sh file and place it in your texture pack's directory, next to the texture pack's subdirectories. Adjust the variables to match your texture package. Then just run the script: A mtr file should be generated, containing entries for each texture based on the maps it offers. #!/bin/bash # idTech4 material generator, by MirceaKitsune # texture pack info name="mypack" author="myself" # file and directory paths base="textures/mymod/${name}" mat="tdm_${name}.mtr" ext="tga" # special maps map_glow="glow" map_norm="norm" map_gloss="gloss" map_reflect="reflect" cubemap="env/gen2" # special parameter param="metal" rm "./${mat}" echo "// Name: ${name}" >> "./${mat}" echo "// Author: ${author}" >> "./${mat}" echo "// Material Directory: ${base}" >> "./${mat}" for d in *; do if [[ -d "${d}" ]]; then cd "./${d}" for f in *.tga; do if [[ -f "${f}" ]] && [[ "${f}" != *"_${map_glow}.${ext}"* ]] && [[ "${f}" != *"_${map_norm}.${ext}"* ]] && [[ "${f}" != *"_${map_gloss}.${ext}"* ]] && [[ "${f}" != *"_${map_reflect}.${ext}"* ]]; then f_noext=$(echo "${f}" | cut -d "." -f 1) echo "" >> "../${mat}" echo "${base}/${d}/${f_noext}" >> "../${mat}" echo "{" >> "../${mat}" echo " qer_editorimage ${base}/${d}/${f_noext}" >> "../${mat}" echo " description \"${name}, ${d}, ${f_noext}\"" >> "../${mat}" echo "" >> "../${mat}" echo " ${param}" >> "../${mat}" echo "" >> "../${mat}" echo " diffusemap ${base}/${d}/${f_noext}" >> "../${mat}" if [[ -f "${f_noext}_${map_norm}.${ext}" ]]; then echo " bumpmap ${base}/${d}/${f_noext}_${map_norm}" >> "../${mat}" fi if [[ -f "${f_noext}_${map_gloss}.${ext}" ]]; then echo " specularmap ${base}/${d}/${f_noext}_${map_gloss}" >> "../${mat}" fi if [[ -f "${f_noext}_${map_glow}.${ext}" ]]; then echo "" >> "../${mat}" echo " // Glow" >> "../${mat}" echo " {" >> "../${mat}" echo " blend add" >> "../${mat}" echo " map ${base}/${d}/${f_noext}_${map_glow}" >> "../${mat}" echo " }" >> "../${mat}" fi if [[ -f "${f_noext}_${map_reflect}.${ext}" ]]; then echo "" >> "../${mat}" echo " // Reflection" >> "../${mat}" echo " {" >> "../${mat}" echo " maskcolor" >> "../${mat}" echo " map makealpha(${base}/${d}/${f_noext}_${map_reflect})" >> "../${mat}" echo " }" >> "../${mat}" echo " {" >> "../${mat}" echo " blend gl_dst_alpha, gl_one" >> "../${mat}" echo " maskalpha" >> "../${mat}" echo " cubeMap ${cubemap}" >> "../${mat}" echo " texgen reflect" >> "../${mat}" echo " }" >> "../${mat}" fi echo "" >> "../${mat}" echo " // Frob highlighting" >> "../${mat}" echo " {" >> "../${mat}" echo " if ( parm11 > 0 )" >> "../${mat}" echo " blend gl_dst_color, gl_one" >> "../${mat}" echo " map _white.tga" >> "../${mat}" echo " rgb 0.40 * parm11" >> "../${mat}" echo " }" >> "../${mat}" echo " {" >> "../${mat}" echo " if ( parm11 > 0 )" >> "../${mat}" echo " blend add" >> "../${mat}" echo " map ${base}/${d}/${f_noext}" >> "../${mat}" echo " rgb 0.15 * parm11" >> "../${mat}" echo " }" >> "../${mat}" echo "" >> "../${mat}" echo " // TDM Ambient Method" >> "../${mat}" echo " {" >> "../${mat}" echo " if ( global5 == 1 )" >> "../${mat}" echo " blend add" >> "../${mat}" echo " map ${base}/${d}/${f_noext}" >> "../${mat}" echo " scale 1, 1" >> "../${mat}" echo " red global2" >> "../${mat}" echo " green global3" >> "../${mat}" echo " blue global4" >> "../${mat}" echo " }" >> "../${mat}" echo "}" >> "../${mat}" fi done cd ".." fi done