Deborah R. Fowler
Command Line Rendering in Houdini
Posted on Aug 21 2018
Updated June 24 2024
In Windows
Personally, I use this method of rendering all the time. I love command line on my home machine! Note in 19.5.303 the Command Line Tools XX.X.XX is no longer available from the start menu as it was in previous versions. It was just a shortcut to the hcmd command in the bin. You can pin the hcmd command to the start menu, but this opens with a path that is not your home directory. Easiest is to use the Houdini Launcher and under Launch select Command Line Tools
The following applies to mantra, however it also works with Redshift! Just change the rop node
If you do not have access to linux and are on windows you can command line render. I have tested the following with 18.0.287 (Apr 8 / 20), 18.5.351 during Winter quarter, 19.0.383 in (Spring 23) and 19.5.303 (Spring 24)
- Open a
"Command Line Tools XX.X.XXX" window (where the Xs represent
the version of houdini).
- You
will find the command line tools window listed under the
start menu in Houdini's program folder. This is simply a
cmd window with the Houdini environment variables/paths
properly set
- you can
also access it from C:\Program Files\Side Effects
Software\Houdini XX.X.XXX\bin\hcmd.exe (either puruse to
the location and double click or type this in a regular
cmd window)
- cd to the
folder where your hipnc file is located and then type
Method1:
- hscript nameOfFile.hipnc
- you will likely see a number of messages about Redshift and then Entered ... session mode.
- you are
now in your houdini file
- cd out
- ls
- render
mantra1
- or whatever you have named your mantra node
- quit to exit from hscript (you could also write the above as render mantra1; q)
- OR opparm -c mantra1
execute; q
Method2 (preferred with scripts below):
- hython "C:\Program Files\Side Effects
Software\Houdini XX.X.XXX\bin\hrender.py" nameOfFile.hipnc
-d mantra1 -e -f 1 10
- So for example I might want to render 10 frames, I would type the above with the current version:
- hython "C:\Program Files\Side Effects Software\Houdini 19.5.303\bin\hrender.py" test.hipnc -d mantra1 -e -f 1 10
Your render will launch and put your results as per instructions in your mantra node.
You can also put this in a Mantra script to save typing. Here
is a very straightforward implementation. Feel free to add user
input such as name of file, frames etc.
Note that it is not necessary to have current1, current2,
current3 - could have just used one variable name.
Modify with your
filename.hipnc and the version of houdini as well as your
mantra node name
Even better, use this with Redshift -
as above but -d Redshift_ROP. Here is a Redshift
example script
Modify with your filename.hipnc and the version of houdini as
well as your mantra node name
I like to have a script to do multiple jobs to keep my computer
busy when I am away. I call it runAway.py and place a number of
these pairs of commands. That way I can queue up multiple jobs
(I don't have a personal farm but running Redshift and Mantra
allow me to get the most out of my resources).
os.chdir("C:/Users/Deborah/Desktop/SRCWebSite/HoudiniResources/Illusions/RubiksCubeVellum/commercial")
os.system("python runRenders.py")
In Linux
In linux you can replicate the behavior that is completed on the
renderfarm. If you are having difficulties with differences or
errors on the renderfarm the first thing I will ask you is if you
have tested it using command line rendering. (Hint: with
simulations or a heavy network you can cache
geometry.)
For example in Redshift:
hrender -d Redshift_ROP_Final yourfilename.hiplc (hipnc if you use the educational or non-commercial version)
For example in mantra:
hrender -d mantra1 testSphere.hipnc
This assumes mantra1 is an output rop in the hip file.
hrender -e -f 1 3 -v -d mantra1 testSphere.hipnc
-e -f 1 3 instructs it to render frames 1 through 3
-v verbose
-d output driver
Type in hrender to see all the options (for example -o test.'$F4'.exr added to the line above would write the information to the files if you have not specified them in your mantra node.)
Troubleshooting on the farm - render locally with command line as a first step to debugging the problem by copying the command from the log file and running it in a terminal window (with renderfarm references removed).
There are a number of ways to launch the command to test. As specified above. Or using hython or a bash script launching hython. This came up due to the linux behavior on the farm with capitalization of the extension .png or .PNG. Long story short, ensure you are using the EXACT name and capitalization when on the farm. On windows and locally on linux both .png and .PNG will work. Not so on the farm. For completeness the command are:
- hython "/opt/hfs19.0.383/bin/hrender.py" -d mantra1 test.hipnc
- or as a bash script (see
attached)
- the bash script above must be made to have executable permissions (chmod +777)
- it then requires parameters - it is essentially given you the hrender command, similar to the windows scripts above
- usage ./bashHython -d mantra1 test.hipnc
- hrender as described below
In the log file you will see:
- hrender -e -v -f 250 250 -o /tmp/farm/Job_285332/blahblah.$F4.exr -d mantraTest /pathblah/blahblah.hipnc
- hrender -e -v -f 250 250 -o blahblah.exr -d mantraTest blahblah.hipnc
OR if you want multiple frames
hrender -e -v -R -f 1 250 -o blahblah.'$F4'.exr -d mantraTest blahblah.hipnc
NOTE: Those are single quotes around $F4 not backticks (located on the key to the left of the enter key on your keyboard). Tested on vlab 3/6/2021
(Note: if you have saved geometry into a bgeo.sc file any texture material overrides will use an expanded path so you may need to have a dedicated shader for that object rather than a texture override. May 24 - I don't believe this is true anymore - will test.)
For caching command line render
hscript file.hip
cd /out
render -vA (verbose, alfred style) -I (that is an I as in interleave) nodetoprocess ... so for example it looks like
render -vA -I merge1
You can do the same thing in windows from the Houdini Command Line Tool window (it's a cmd window with the proper paths/environment set) (It is in the All Programs/Side Effects Software /Version/Utilities/Command Line Tools)