Blender

Blender is a free and open source 3D animation suite

Introduction

Blender is a powerful and open-source 3D graphics modeling and animation software. It is capable of handling the entire pipeline of 3D graphics from modeling to rigging all the way up to rendering and video editing. It even comes equipped with a game engine.

Using Blender on RCC Resources

Blender is installed in RCC resources in such a way that you create your .blend file in your workstation and then upload the file to submit Blender jobs to HPC. A single node Blender job can be submitted using the following submit script.

#!/bin/bash
#SBATCH --job-name="blender"
#SBATCH -n 1
#SBATCH --ntasks-per-node=4
#SBATCH -p genacc_q
#SBATCH -t 1:00:00

module load blender

blender -b file_name.blend -o ///YourOutputDirectoryRelativeToLocationOf.blendFile/OutputFilePrefix_ -s 1 -e 100 -t 4 -a

In the above example, four cores are used (ppn = 4 in line 4) in a single node (node = 1 in line 4) and therefore, Blender uses four threads (-t 4 in line 10) to create frames 1 to 100 (-s 1 -e 100 in line 10) of the given file_name.blend file. The output is saved into a sub directory inside the directory where the .blend file exists and the path is given relative to this directory (using //). Other command line options can be found in Blender documentation. Note that the order of the arguments in line 10 does matter and mixing the order may result in the output not being generated in the desired location (or no output at all). One can use a variation of this script to submit individual frames to nodes. In this case, line 10 of the above script would be,

blender -b file_name.blend -o ///YourOutputDirectoryRelativeToLocationOf.blendFile/OutputFilePrefix_ -f 1 -t 4 -a

Here, it is only doing the first frame instead of 100 frames. A shell script similar to the one shown below can then be used to submit individual frames to different nodes.

    #!/bin/bash

    f_start=1
    f_stop=100
    f_inc=1

    fs=$f_start

    while [ $fs -le $f_stop ]; do
         fe=$(($fs + $f_inc))
         if [ $fe -gt $f_stop ]; then
         fe=$f_stop
         fi

        cat <<EOS | sbatch 

        #!/bin/bash
        #SBATCH --job-name="blender"
        #SBATCH -n 1
        #SBATCH --ntasks-per-node=1
        #SBATCH -p genacc_q
        #SBATCH -t 00:10:00

        module load blender
        blender -b CubeRenders.blend -o ///test/cubes_ -s $fs -e $fe -a

        EOS

        fs=$(($fs + $f_inc + 1))

    done

f_start and f_stop in lines 3 and 4 are the frames that needs to be done (1 to 100 in this example). The queue name in line 21 needs to be edited to run in specific queue. Copy the above script and change the .blend file to your .blend file and save as blender_submit.sh (you can use any name). Set the permissions on your script to executable,

chmod 0755 blender_submit.sh

and execute,

./blender_submit.sh

to submit all the jobs. If you have a large number of frames, not all frames will process at the same time. However, when all individual jobs are finished, you will have all the frames saved to your specified directory. If you have a very large number of frames, then above script can be slightly modified by changing f_inc to the number of frames processed by a single job to submit a range of frames as an individual job rather than a single frame. You will only have to modify lines 3-5 and line 26 to submit your Blender job.

After all fames are finished, Blender's built in Video Sequence Editor (VSE) or any other package can be used to create the desired video file.