In order to fully unlock the power of the Maya renderer, you need to render your scenes in DOS. Rendering in DOS can be up to twice as fast as rendering from within Maya, depending on your processor and version of Windows. In addition, there are an array of useful functions that you can perform in a DOS render that are difficult or impossible from within Maya. Furthermore, you can manage multiple scenes and make changes to render settings instantly.
Before I get any further, it's worth mentioning that we're not actually using DOS. It's really just the Window's command line. It looks like DOS, and a lot of people still call it that, but technically, it's still Windows, just without the GUI. I generally switch back and forth between referring to it as DOS and the command prompt.
Okay, let's get started with the tutorial.
First, make sure Maya and any other computer-heavy programs are closed. They don't have to be, but the whole idea is to eliminate the overhead.
Open up the directory containing your Maya scene and right click on it to reveal the drop-down menu. Click "render," and off it goes, rendering in DOS. It's that easy! A DOS window will open up, displaying various render diagnostics. These allow you to keep tabs on your render.
Hopefully you'll see an increase in render speed. It's not always a big difference, but like I said earlier, sometimes it's huge. To stop the render at any time, just close the DOS window.
Alright, on to the cool part:
You can create files called bat files that contain lines of DOS code in order to set up batch renders and change various render settings. By double clicking on the file, you can launch the code without opening the command line.
Create a txt document in the same directory as your Maya scene by right clicking and selecting New > Text Document. Open up the text document and type in render, followed by your scene name. eg:
Save the file, and rename it something like pumpkin_batchrender, and change the extension from "txt" to bat. Windows might panic and give you a warning message, but you can ignore it. Now, double click on the file. Again, Windows might panic and say something like: "Are you sure you want to launch this program?" Click yes and your scene will once again begin to render in DOS
Now we're getting somewhere. But it gets even better. By using command flags, you can change the render settings in your scene without opening it up every time.
render -s 1 -e 100 set_shot01.mb
The flags 's' and 'e' set the start and end frames of my render to 1 and 100.
render -im myImages pumpkin_cry.mb
The flag 'im' sets the image file output name to 'myImages'
Ever want to set up multiple Maya scenes to batch render before you leave for the weekend? Not a problem. Just type them in on separate lines, and they'll render consecutively. eg:
Similarly, you can use the '-cam' flag to render one scene with different cameras for different ranges:
render -s 1 -e 100 -cam cameraWS pumpkin_hop.mb
render -s 101 -e 186 -cam cameraCU pumpkin_hop.mb
render -s 187 -e 213 -cam dollyCam pumpkin_hop.mb
Other flags include -rd to set the directory that the files render into, -r to choose software, hardware, or mental ray, and -preRender to execute a line of MEL before rendering. Here's a complete list of Maya Render Flags
I hope you're still with me, cause I've saved the best for last. You can use the flag '-rep' followed by '0' or 'off' to prevent the renderer from overwriting already existing frames. Useful for avoiding accidentally overwriting important renders. Even more useful for setting up a distributed rendering farm.
If you have multiple computers sharing a network drive, you can create a bat file with the '-rep 0' flag and start up the render on all your machines. They will all render together, and they will know to skip existing frames. So if Computer A is rendering frame 35, Computer B will go on to render frame 36. Your renders will be done in no time!
render -rep 0 myMayaScene.mb
Pretty cool, huh?
A couple of troubleshooting notes before we finish today: bat files will run into errors if you have directories or files with spaces in their names. It's good computing practice anyway to avoid spaces and use underscores, so you'll need to get into the habit if you're going to use bat files.
Also, if you have Maya scenes in different directories and you want to render them from a single bat file, it is possible to do so. The bat file does not actually have to be in the same directory as your scene. It is just easier to do it that way. If your scenes and bat files are in separate folders, just make sure to type in the entire path of the scenes in your bat file. Like so:
That's it for today!
I hope that you enjoyed the lesson. Feel free to email me with any questions or corrections. I hope you'll visit again and check out some more tutorials. Or check out my weblog: Set Driven Key, for animation news, updates, and Maya tips.