Está en la página 1de 7

Batch Rendering Multiple Maya Files

By Brian Immel
Suppose you have animated your heart out and you are ready to render. The only problem is that
you have sixteen million scenes with three camera changes each. That's a lot of rendering
especially if you don't have an render farm at your disposal! You could stay up all night baby-
sitting your machine but there is a easier way. Batch command rendering! In this tutorial, I give a
few examples of simple batch commands using a text editor such as Window's Notepad to write
a series of instructions for rendering non-stop scene files.

Command Scripts Final Thoughts FAQs Common Render Switches Notes on Mental Ray

Command Scripts
1. The first step is to finalize your render globals in your scene file. Refer to the image to the
right for example. The batch commands we are going to write will override these global settings.
However, we want to set these regardless in case we don't use all the flags/arguments in the batch
commands.
Note: if you are moving files from one directory or machine to another, you'll may have to re-
link texture files unless you copy the exact same file/folder structure you have (i.e. copy the
entire Maya directory). Example if you have your texture files in a folder called "texutres", you'll
need to copy your texture files to a folder called "textures" in the new directory. It's important
not to have any spaces in your folder names or Maya file names. The render commands thinks
that a space between words is a argument or action and will cancel that render.
Tip for Naming directories and scene files:
• Wrong: D:\Maya folder
• Wrong: render Maya file.mb
• Right: D:\Maya_folder or D:\Maya-folder
• Right: render Maya_file.mb or render Maya-file.mb

2. Okay, now its on to the nitty-gritty. Lets open up Notepad and start writing our list of files to
render.

3. Type in command line like you normally would in the command prompt/dos shell. In the
example below, I wrote a one line batch command that will render a maya scene file called
mayafile.mb using all processors, start at frame 1 and end on frame 30, rename the output image
to new_image_name, change my render directory (d:\scene2\shot3). Click here to see list of
standard command switches. For more switches, go to the command promt and type: render
-help

4. Having just one command line will render just one file. Let's say you want to render the same
file but with multiple cameras that you set up in the Maya file. Copy the command line and paste
it to the next line down. Then add the switch -cam cameraname replacing cameraname with the
camera you wish to use. You can put switches anywhere between the main command (render)
and the Maya file (scene2.mb). You can also batch render different Maya files also (scene3.mb,
scene4.mb and so forth.)

5. Continue copy/pasting until you get all your cameras in that Maya file you want to render out.
6. I like to change all the image names to reflect which camera they came from like that of
example below. I change the names so the files won't render over themselves. Instead using the
-im switch, you can just render to another folder as long as it exists (shot01, shot02, shot03, etc.)
to keep your image files from rendering over each other.
7. The next and a very important step is to save this text document into an executable file. Go to
File > Save As..., name the file whatever but type in the extention .bat. Save as type to All
Files. If you don't save this file with the .bat extension it won't be executable.
8. Make sure you save the batch file in the same directory as your Maya file. Otherwise, you will
need to write in which directory to find the scene fill in question.
Exmple:
render -n 0 D:\Maya\scenes\scene2.mb
render -n 0 D:\Maya\scenes\scene3.mb
This particular set of batch commands can be executed from anywhere because we list the
absolute path for the scene file.
9. To run the batch file, just double click on it from your windows browser. A command window
will open and the Maya rendering engine loads the first file in the command list to start
rendering.
10. Now the Maya rendering engine will render every command line in the order you typed it in
until it runs out of commands. As soon as it completes one rendering task, it go on to the next
automatically. In the example given is step 6, Maya's rendering engine will render all four
commands and place each shot in a different directory.
If you want to copy and move files automatically at the end of a render, add the following line to
the end of each render:
xcopy <render_drive>:\<render_directory> <new_drive>:\<new_directory> /i /s /y
This will copy all your images (and directories) to your new directory of choice. Replace
<new_drive>:\<new_directory> with whatever folder structure you like.
So a happy batch file will look something like this (assuming the scene files are in the same
directory as the batch file):
render -n 0 -s 1 -e 3 -im shot01 -rd D:\scene2\shot1 scene2.mb
render -n 0 -s 1 -e 30 -im shot2 -cam camera01 -rd D:\scene2\shot2 scene2.mb
render -n 0 -s 20 -e 30 -im shot3 -cam camera02 -rd D:\scene2\shot3 scene2.mb
render -n 0 -s 45 -e 100 -im shot4 -cam camera1 -rd D:\scene2\shot4 scene2.mb
render -n 0 -s 200 -e 300 -im shot5 -cam camera3 -rd D:\scene2\shot5 scene2.mb
Top

Final Thoughts
Another advantage to using the command line to render, you are not using Maya's interface to
render with. This means more computing power to your renders and less wasted time.
Never ever ever render to a movie file (.avi, .mov, etc.). If your render fails, you will have to
start all over again with the entire render. Plus, you will be giving up all sorts of control over
image quality (rendering in layers, render passes, alpha channels, z-depth, etc.) by rendering to a
movie file. In most cases, Maya will render faster if you are rendering in frames (such as .tga,
.tiff, .iff) and composite/edit your frames back together in composition software like After
Effects.
I strongly encourage you to use all available (-n 0) processors regardless of how many processors
your machine has. By using this flag, Maya will know to use whatever resources Windows is
willing to give up to the render engine and maintain stability within your system. However, if
you tell the render engine to use just one processor (-n 1) and your machine has only one
processor, Maya will eventually use up all your system's resources and crash taking with your
last rendered frame with it.
Top

FAQS
1. If one of your Maya files doesn't render, check to see if there is a one of the following
problems:
○ Typo in the command line (extra spaces, misspelled switches, file names, etc.)
○ Non-renderable cameras
○ Non-existant directories
2. "I double click my batch file to render and the command prompt opens but instead of
rendering, the screen rolls with text."
○ Answer: This means that something in you scene file is corrupt and most likely,
its the camera you're trying to render through. Solution: Open up that scene file,
make a new camera, copy/paste the old camera's info onto the new camera and
delete the old one. Rename the new camera to the old camera's name (if named).
Save the scene file.
3. "I double click the batch file to render and Notepad opens up the file."
○ Answer: The batch file was not saved with the .bat extension. The .bat extension
makes the file executable.
If something in this tutorial doesn't make sense, please email me at brian@jawa9000.com.
Happy rendering!
Top

Common Render Switches


Switch Argument/Command
-s <#> Start rendering at frame (replace # with a number); -s 15
-e <#> End rendering at frame (replace # with a number); -e 45
-n 0 Use all available processors for rendering; -n 0
-cam <cameraname> Render from camera; -cam camera1
-rd
<drive>:\<foldername> Render to directory; -rd c:\maya\project\images

-im <new_image_name> Rename image name (this won't affect the file extension); -im
newRender
-log <log filename> Saves output information into a log file (log.txt works nicely)
-r <render type> Specify which type of renderer to use
Return to Step 3
Top
Notes on Mental Ray
If you are attempting to render with Mental Ray, you will need to add the following line to your
command:
-r mr
This flag, -r, stands for renderer and mr is for Mental Ray. Even though you set the renderer
within the Maya file to Mental Ray, the command line renderer defaults to Software. Side note:
Your batch render will error out if the Mental Ray plug-in is not installed and enabled. You may
have to add additional Mental Ray flags and values to your batch file if the render doesn't turn
out right in the first place. For reasons that are beyond me, not all of the Mental Ray values (or
even the basic render settings) are passed to command line for batch rendering.
For more information on using batch rendering with Mental Ray, open up a command line and
type this:
render -help -r mr

Happy rendering!
Top

También podría gustarte