'Maya'

 
'Command Line Rendering'
by
Peter Stratton


Let’s say you have changed your mind, and instead of rendering frames 1 – 350 (which were set in the Maya render settings window), you want 10 – 350: -s startFrame -e endFrame -b byFrame (Fig.15).

(Fig15)

Remember, the flags are only overrides – all the other settings are going to be read from the Render Settings window of the file!

Let’s say you want to specify a different camera for the render: Render -r mr -cam persp yourFileName.mb

Here is the official point where this gets cool!

Let’s say you want to render hundreds of images for your animation while you continue working on your term paper and listening to music.  You can tell the renderer how many of your processors to use.  So I am running a dual-core CPU in my home machine; by specifying 1 processor, I have been rendering out hundreds of images while I worked on this PDF!  Note the different flags for Mental Ray and Maya.  On a quad core, you could use two or three processors and still work on other stuff.

Render -n 1 yourFileName.mb // this renders with one processor using the Maya Renderer

Render -rt 1 -r mr yourFileName.mb // this renders with one processor using Mental Ray

Remember how you made all those extra folders in your project’s images directory for all the camera shots you intended on rendering?  Unfortunately, the images folder you specify in the Maya Project window is UNIVERSAL for the project.  What that means is you can't just open each individual shot file and change the image folder – it will change it for every other file in the scene. 

This is how you direct the images into them.  I am going to direct my gears.mb renders to a folder named “gearPanAndZoom”:

Render -r mr -rd DIGM211\ MidTerm\images\gearPanAndZoom gears.mb

And here is where it all comes together!  Let’s say you want to render every single shot in your animation and go home to get some sleep.  What a concept?!  Open up Notepad; we are going to create a batch script – a simple executable file that will run shell commands in order with very little work from you.  For this you don't even have to open the command prompt window (Fig.16).

(Fig16)

You can use whatever flags you want in the script.  The one in Fig.16 tells the computer to:

Render -using one processor -using mental ray and -where to save the images -for each scene

Again, any information you don't specify with flags will be derived from whatever was specified in Maya's Render Settings window when you last saved your scene.

After you type your commands, go to: File > Save > Save in THE SAME FOLDER AS THE FILES YOU WANT TO RENDER > Choose the “Save As Type” drop down item “All Files” > Name your file and use the extension .bat at the end of the file name. 

For this example: RenderMyStuff.bat

Two important notes:
1.  Do not save your file as a .txt file – it will not run!
2.  Do not name your file “render.bat” – it will execute infinite loops of badness!(Fig.17)


(Fig17)




3DTotal Advertisement - We need your support!





Great!  Now close Notepad and open the project\scenes folder you just saved your .bat file to (Fig.18).

See that file with the little gear symbol on it?  It's a .bat or “MS DOS batch” file.  The one you are looking at is the one I’m using this (Friday) afternoon while I work on this.  There are others in there, including the “RenderMyStuff.bat” we just made. If you were to double-click one of the .bat file icons, a command prompt window would open and tell you what it is doing, and whether there are any problems. 

Provided your file paths are all correctly written and your flags make sense, the lines of code you typed in notepad would begin executing and would continue executing until the computer runs out of commands.  You type Control C, or your system crashes (which will happen, but not nearly as often as if you try and render from inside Maya, which brings us full circle to why you want to render this way in the first place).

(Fig18)

Step 4:

In closing, you've double-clicked your .bat file, the command prompt window has opened and no errors have been returned.  What I usually do is press “Control + Alt + Delete” and this opens up the Windows Task Manager.  Click the “performance” tab at the top.  The CPU Usage windows show you how much of your available processing power is being used.  On a side note, each “CPU Usage History” window represents a single processor.  I'm running a script in the background using 50% (or 1 processor) (Fig.19). 

I'll then open up the folder to which I am directing my rendered images, to make sure they are going where I expect them to and saving in the proper format.  If you are curious, you can then time how long each file is taking to render (based on how long it takes between file icons to appear in your folder).  You can then decide if you are going to have your MidTerm project done in time for the crit.!

When I'm working in a shared environment I'll also put up a plain Notepad text file explaining what frames I am rendering (in case it finishes and someone else needs the computer), and what my contact number/email is in case there are questions or problems. 

Enjoy!


(Fig19)

Page 3

Discuss this Tutorial in our Forums here!


To keep up with the latest Tutorials and Interviews on 3DTotal, sign-up to the free
Bi-monthly Newsletter Here!