Last active
June 19, 2019 00:42
-
-
Save Jackzmc/94a0d21050cb088ebfb282d5f1fc6509 to your computer and use it in GitHub Desktop.
scripts to render blender .blend files, either with renderblender CPU or cycles GPU, and auto zipping up final result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#category: setup arguments | |
main_setup() { | |
if [ $# -eq 0 ]; then | |
echo "Please specify a .blend file" | |
exit | |
fi | |
#category: modify arguments | |
blend_file=$1 | |
shift | |
zip_file=${blend_file%".blend"} | |
zip_file=${zip_file#"blends/"} | |
if [[ $# -ge 2 ]]; then | |
framearg="--render-frame ${1}..${2}" | |
shift 2 | |
else | |
framearg="-a" | |
fi | |
if [[ ! $blend_file == *.blend ]]; then | |
blend_file=${blend_file}.blend | |
fi | |
if [[ ! -e $blend_file ]]; then | |
if [ ! -f "blends/$blend_file" ] ; then | |
echo "Blend file missing, and not found in blends folder" | |
exit | |
else | |
blend_file="blends/$blend_file" | |
echo "Found blend file in blends folder" | |
fi | |
fi | |
} | |
#category: clean up & archive | |
checkTmp() { | |
#check if files were generated | |
if [ -z "$(ls -A /home/ezra/tmp)" ]; then | |
echo "No files were generated in ~/tmp" | tee -a logs/blender.log | |
exit | |
fi | |
} | |
#if pre-existing .zip, make new | |
createZip() { | |
if [[ -e "zips/${zip_file}.zip" ]]; then | |
counter=1 | |
# until a zip file doesnt exist, then keep looping | |
until [ ! -e "zips/${zip_file} (${counter}).zip" ] | |
do | |
((counter++)) | |
done | |
#todo: add duplicate" | |
zip_file="${zip_file} (${counter})" | |
fi | |
zip -j -r "zips/${zip_file}.zip" /home/ezra/tmp/* && | |
rm /home/ezra/tmp/*.png | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
. "./render.sh" | |
#category: setup arguments | |
main_setup $@ | |
echo "Running CPU Blend for $blend_file ($(blender -b --version))" | tee logs/blender.log | |
# run blender | |
(blender -b "$blend_file" -noaudio --render-output "/home/ezra/tmp/" -P python_scripts/settings.py -P -y ${framearg} | tee -a logs/blender.log ) 3>&1 1>&2 2>&3 | tee logs/blender_errors.log | |
#category: clean up & archive | |
checkTmp | |
createZip | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
. "./render.sh" | |
#category: setup arguments | |
main_setup "$@" | |
echo "Running GPU Blend for $blend_file ($(blender -b --version))" | tee logs/blender.log | |
# run blender | |
(blender -b "$blend_file" -noaudio --render-output "/home/ezra/tmp/" -E CYCLES -P python_scripts/settings.py -P python_scripts/render_gpu.py -y ${framearg} | tee -a logs/blender.log ) 3>&1 1>&2 2>&3 | tee logs/blender_errors.log | |
#category: clean up & archive | |
checkTmp | |
createZip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment