render batch animation layers


#1

I want to batch render a scene as many times as there are animation layers in it (except for the BaseAnimation layer).
So every time with 1 animation layer ON and the other animation layers OFF. The rendered png’s having the name like so: animationLayer_001.png

It’s a script I’d put in a .bat file, so far I managed to always use code lines like this one below to render out my scenes:
“C:\Program Files\Autodesk\Maya2018\bin\render.exe” -r redshift -rd “D:\GameDevelopment_Unity Projects\Sparks Prototype\Assets\Graphics\Animation QuickTest” -cam RenderCam -of png “D:\GameDevelopment_Maya_Projects\Our Game Characters\Bowman\scenes\Walk\Walk_MASTER.ma”

but this time it requires a more complicated process, does someone know how to solve this?


#2

You are overcomplicating this.
Go to the render settings and in the file name prefix in the common tab you will see (not set; using scene name), or who knows, maybe you added a name
Well, right click there and chose from the popup what do you want to use. In your case you will use <RenderLayer>.
As a habbit, I put there renderOutput/<Scene>_<RenderLayer>/<Scene>_<RenderLayer>. So this will make a Renderoutput folder and there a folder named with the scene and layer, and then the file with the scene and layer.

The bat file can be a lot simpler as well:

set PATH=%PATH%;C:\Program Files\Autodesk\Maya2017\bin
render -proj LOCATION_OF_YOUR_PROJECT scenes\YOUR_FILE.ma
echo “OMG, the rendering is finished, yeeey”
pause

And that’s it. In this case it will go trough each layer one by one and render it.
the first line will add the maya bin folder to the path environment variable so you can just type render, instead of the full path. The second line is just the command, with the flag for your maya project and of course relative path to the scene. echo “OMG, the rendering is finished, yeeey”, will just print that line to the window. And pause just asks you to press any button to close the window
In the second line you can specify which layers to be rendered and which not. I prefer to set this up in the maya scene and set up the cameras as well.


#3

why not save out several maya files… or export direct to .ass or .vrscene.?


#4

For Leionaaad:
Ah yes, thanks for the tips but what you propose is not for ANIMATION layers but RENDER layers.

The reason I need this is because I want to render different animations, my bowman must shoot in various directions:
https://www.youtube.com/watch?v=4sjqUG8JJng&feature=youtu.be

During this video I’m enabling a new animation layer and disabling the previous one every few seconds.

For oglu:
Because I want to be able to change the base animation easily should the animation have to change in the future, navigating from file to file takes time.


#5

Ok I managed to make a Maya script mel script to change animation layers one by one. It works within maya but strangely enough when adding this:

  • preRender “windowsPathToMelScript”

in the render.bat file it’s not doing anything.

Here’s the script:
string $root = animLayer -query -root;
string $layers[] = animLayer -query -children $root;
int $index = -1;
for ($layer in $layers)
{
int $isMuted = animLayer -query -mute $layer;
print $isMuted;

$index++;
if ($isMuted == 0) break; 

}
// mute all layers
for ($layer in $layers)
{
animLayer -edit -mute 1 $layer;
animLayer -edit -lock false $layer;
}
//set next layer on
$index = ($index + 1) % size($layers);
animLayer -edit -mute 0 $layers[$index];
print $layers[$index];