After not having exercised for four months, I’m finally back at it again and I feel shredded!
I like feeling lean and healthy. Makes me feel good and all tingly inside. Just like exercising, I like my machine to be lean when I’m rendering especially since I work on an old machine. I’m not like all you cool kids with the fancy Octane boxes. So I like to give my render all the resources possible to do its job. This is why I like command line renders. I do it in After Effects all the time.
After Effects Command Line Render:
aerender -project ~/Desktop/30-days/to/six-pack-abs.aep
As you might have guessed, you can do the same in Houdini. Now, I’m not going to get into the whole “it doesn’t make a big difference…blah, blah, blah” deal. If my OS does not have to waste resources drawing the UI, I’m fine with the placebo effect. Just like exercising, I feel good about it.
Command line rendering is not programming for those of you about to close the browser window or tab. It’s just typing a few words in the shell. It really comes down to calling a render command with a few options thrown in.
Now, before we continue, I’m on OS X so that means I’m using the Terminal and I have my environment set up to initialize Houdini when I launch a Terminal session. If you need help with this, refer to my previous post on setting up your environment.
If you’re on Windows, it may work similarly. I don’t have a Windows box so can’t really say. Other than that, on OS X you can use the Houdini Terminal setup provided by Side Effects. You will find it in your Houdini installation directory under the Utilities folder. Again, not sure if the Windows install provides something similar. Yeah, yeah, make fun of my underpowered Mac.
Command Line Magic
Lets say I have a .hip file called ripped.hip that has a Mantra node called mantra_out. At the most basic level, you can start a render with the following command:
hrender -d mantra_out ripped.hip
This will process the ripped.hip file with whatever settings you set in your Mantra node when you saved out your .hip file. This is the
hrender command followed by the output driver and the .hip file name.
One important things to take notice. The
-d option is required. This specifies the output driver. In our example, it’s a Mantra node but you can use a geometry node to save a .bgeo file to disk. You need to provide the
-d option with the name of your output driver node exactly as you named it in your Houdini file. In this example, I named my Mantra node mantra_out and this is what I used after the
You can get fancier of course and alter a few of the render settings. For example, lets say I wanted to command line render this file from frames 10 to 70 to check a section of my render. I wouldn’t need a full size render for preview so I would type in my shell:
hrender -e -f 10 70 -v -w 640 -d mantra_out ripped.hip -o preview-’$F’.jpg
The hrender is your render command that in turn calls a Python script called hrender.py. This guy does all the work.
-e option tells the render command it will be a sequence of images. If you wanted to specify a single frame, you would leave out
-e and Houdini will render the frame where the timeline marker was left at when you saved your file. If you would like to specify the frame number, use the
-F option followed by the frame number (e.g. -F 12).
-e, you need to use the
-f option. This is a lowercase
f. You add
-f followed by the frame range such 2 59 or 72 9000000000. First number is the start and second number is the end of the frame range.
-v option is verbose mode so you get some info regarding time and the frame currently being rendered. This is optional.
Since this is a preview, I want a smaller image. In order to do this, I passed the
-w option which specifies the output width. You can also use the
-h for a height output but if only one option is specified, aspect ratio will be maintained based upon aspect ratio of output driver.
As I previously mentioned, the
-d option specifies the output driver. In other words, the node in your scene that will do the rendering. This option is required so this is why you need to remember what you called your node.
The ripped.hip is the file name. No surprises here.
-o options give you the ability to override the image file name and type. If left out, it will use the values specified in the Mantra node when you saved out the file. Notice since I’m rendering a frame range I need to use
$F to specify the frame number WITHIN single quotes. This is very important! If you leave out the
$F or single quote marks, you will only get one image file called preview-.jpg. The frames will overwrite each other.
The reason the quote marks are important is because the Terminal or shell is trying to find an environment variable called
$F and perform parameter expansion. If it doesn’t find
$F with an associated value, it will leave it blank. You need to protect
$F so Houdini can do its own expansion. I used quotes but you could have used a backslash such
-o preview-\$F.jpg and that would work as well.
Command line rendering is super useful especially when you combine it with other scripts or commands. For example, if I have an After Effects project that contains an image sequence rendered out of Houdini and I need to make changes to the Houdini file, I have to re-render in Houdini and After Effects.
After making my changes to the Houdini file, I can automate the Houdini and After Effects renders from the shell without having to open up any GUIs.
I’ll show you next week how to do this but for more info regarding batch renders and command line rendering, head on over to the docs. I simplified a lot of this because Houdini does a lot behind the scenes and provides greater flexibility when it comes to rendering.
Time for some burpees!