Unlimited batch rendering with xsibatch -processing


Hat tip: Andy Jones on the Softimage mailing list

You can use xsibatch -processing to render scenes with third-party renderers like Arnold. With -processing, xsibatch uses a Processing token instead of a Batch license, so you’re not limited by the number of Batch licenses you happen to have. Back in the days before third-party renderers, -processing for was for non-rendering tasks. Now it’s for non-mental ray tasks!

I was sure I tested this long ago, but obviously I must have made a mistake on my command line.

xsibatch -processing -render //server/project/Scenes/example.scn

=======================================================
 Autodesk Softimage 11.1.57.0
=======================================================

License information: using [Processing]
# INFO : [sitoa] SItoA 2.7.1 win loaded.
# INFO : [sitoa] Arnold 4.0.12.1 detected.

Here’s actual proof in the form of a screenshot :)

xsibatch_processing_render

Writing a python script for processing scenes with xsibatch


Here’s the basic skeleton of a Python script that calls xsibatch -processing -script on all scene files in a given folder.

Python command line:
The python script takes two arguments: the root folder for the location of the scene files, and the name of the script file to run with xsibatch -script.

python process_scenes.pys --dir ""C:\Program Files\Autodesk\Softimage 2013 SP1\Data\XSI_SAMPLES\Scenes" --script "test.pys"

process_scenes.pys:
The python script takes care of finding all the scene files, and then running xsibatch -processing -script on each .scn file.

import os
import fnmatch
import subprocess
import sys
import getopt

XSI_BINDIR=r"C:\\Program Files\\Autodesk\\Softimage 2013 SP1\\Application\\bin"

opts, extraparams = getopt.getopt(sys.argv[1:], "d:s:", ["dir=","script="]) 

#
# Get root directory to scan for scene files
#
SCENES_DIR="C:\\Program Files\\Autodesk\\Softimage 2013 SP1\\Data\\XSI_SAMPLES\\Scenes\\OLD"
SCRIPT="test1.pys"

for o,p in opts:
  if o in ['-d','--dir']:
     SCENES_DIR = p
  elif o in ['-s','--script']:
     SCRIPT = p

#
# Generator function for finding files
#
def find_files(directory, pattern):
     for root, dirs, files in os.walk(directory):
         for basename in files:
             if fnmatch.fnmatch(basename, pattern):
                 filename = os.path.join(root, basename)
                 yield filename

#
# Open each scene file and run the specified script
#
for scn in find_files(SCENES_DIR, '*.scn'):
	sXsiBatch = "%s\\xsibatch" % XSI_BINDIR
	subprocess.call( [ sXsiBatch, '-processing', '-script', SCRIPT, '-args', '-sSceneName', scn ] )

Softimage script test.pys:
A simple test script to run with xsibatch. Note that because the function is named “main”, I don’t have to specify that on the xsibatch command line. I just have to specify the arguments.

def main( sSceneName ):
	LogMessage( sSceneName )	

Setting up Softimage for network rendering


I get asked this question from time to time. It’s actually pretty straightforward to set up…it’s managing the render jobs that may take more effort.

  1. On each render node, install a network-licensed version of Softimage.
  2. During the install, on the Product Information page:

    • Choose Network License.
    • Enter your serial number and the product key 590D1.
    • Enter the name of the license server computer.

Done. It’s all set up now, but there’s a few things you should check/consider:

  • Check that you can run xsibatch on the render nodes and get a license.
    If you have any problems, here’s some troubleshooting tips for xsibatch licensing.
  • Xsibatch needs to have read/write access to wherever you store your Softimage scene files and projects, and wherever you decided to output the rendered images.
    For example, you could have a separate file server for scenes and render output, or it could be the local workstation where you run Softimage.
  • Third-party addons, plugins, and shaders need to be available to the render nodes, either via a shared workstation or by installing them on the render node.
    Note that the user account used to run xsibatch will have a Softimage user folder on the render node.
  • You need a way to manage the render jobs that run on the render nodes. There are a range of possible ways to do this:
    • Manually starting xsibatch on each render node.
      You could either specify specific framesets to render, or use the –skip flag to tell xsibatch to skip frames that are already rendered [by other render nodes]
      For example:

      xsibatch –render “//server/project/scenes/Example.scn” –frames 1-10
      xsibatch –render “//server/project/scenes/Example.scn” –skip
    • Hand-rolling your own tools/scripts to start render jobs (for example, using pstools to start xsibatch jobs on the render nodes, or generating batch files to kick off render jobs)
    • Purchasing render management software (such as Royal Render—you may want to try the demo version)

Moving the timeline pointer back to frame 1 with xsibatch


UPDATE: In the comments, Vladimir suggests a better way to do this: use the scntoc. That way, the scene will always open at frame 1.
Use a text editor to add Application.SetValue(“PlayControl.Current”, 1) to the onload script. This script will run when you open the scene, and move the timeline pointer back to frame 1 to avoid the re-simulation.

   <PostLoadScript>
      <Language>Python</Language>
      <Function>postLoad</Function>
      <Script_Content>
	<![CDATA[
Application.SetValue("PlayControl.Current", 1)
	]]></Script_Content>
   </PostLoadScript>

After you save the scene, Softimage will write out the scntoc without the CDATA section (Softimage will replace special characters like < and ” with entities).

   <PostLoadScript>
      <Language>Python</Language>
      <Function></Function>
      <Script_Content>
	
Application.SetValue(&quot;PlayControl.Current&quot;, 1)</Script_Content>
   </PostLoadScript>


So you have a heavy simulation, and you saved the scene with the timeline pointer at frame 1000. Now when you open the scene, you have to sit and wait while the scene re-simulates.

You can fix this by using xsibatch to move the timeline pointer back to frame 1.

It’s probably a good idea to save heavy sim scenes with the timeline pointer at frame 1 ;-)

  • Save this JScript in a .js file.
    var sScene = "C:\\Users\\blairs\\Support\\Scenes\\Test.scn"
    OpenScene(sScene, null, null);
    SetValue("PlayControl.Current", 1, null);
    SaveScene();
    
  • In a command prompt, use xsibatch -processing -script to run the script:
    xsibatch -processing -script C:\Users\blairs\Documents\resetPlayControlCurrent.js
    

Now you can open your scene without it resimulating.

WARNING – Unknown flag (ignored) : -processing


When you use the -processing flag, you can ignore the “Unknown flag” warning. As long as you see “License information: using [Processing]“, you know that xsibatch is using one of the unlimited processing licenses.

C:\Softimage\Softimage_2010_x64\Application\bin>xsibatch -processing-script hello.js
=======================================================
 Autodesk Softimage 8.0.201.0
=======================================================
        
License information: using [Processing]
        COMMAND: -processing -script hello.js
WARNING - Unknown flag (ignored) : -processing
# INFO : Hello World

Setting a thread limit on rendering


Occasionally I’m asked whether there is some way to limit XSI/xsibatch to just one CPU, so that while a rendering is going on, the user can use the other CPUs for something else.

XSI does have a -thread command-line switch that limits the number of threads created by mental ray for rendering.

For example, if you turn on Progress diagnostics for a scene and then render from the command line:

xsibatch -thread 1 -render "%XSI_HOME%\Data\XSI_SAMPLES\Scenes\red_jaiqua.scn" -verbose on -frames 1-3

Then you will see progress messages like this:

//..
// INFO : JOB  0.5  progr:    91.0%    rendered on EXAMPLE.3
// INFO : JOB  0.7  progr:    91.3%    rendered on EXAMPLE.3
// INFO : JOB  0.4  progr:    91.5%    rendered on EXAMPLE.3
// INFO : JOB  0.5  progr:    91.8%    rendered on EXAMPLE.3
// INFO : JOB  0.6  progr:    92.1%    rendered on EXAMPLE.3
//...

In those progress messages, EXAMPLE is the computer name, and 3 is the thread number. So you can see that the render is using just one thread.

If you were to use -thread 4, then four threads are created:

// INFO : JOB  0.5  progr:    91.0%    rendered on MTL-P1917.5
// INFO : JOB  0.7  progr:    91.3%    rendered on MTL-P1917.7
// INFO : JOB  0.4  progr:    91.5%    rendered on MTL-P1917.4
// INFO : JOB  0.5  progr:    91.8%    rendered on MTL-P1917.5
// INFO : JOB  0.6  progr:    92.1%    rendered on MTL-P1917.6

Unlimited xsibatch processing


As of Softimage 7.5, you get unlimited batch processing. Before, you got 8 Processing tokens with Advanced and 4 with Essentials.

Batch processing is where you run “xsibatch -processing -script”. Batch processing can includes things like exporting .mi2 files, exporting rib files, baking, committing, asset management, custom render management/submission, dynamics, … anything in a complex pipeline that requires automation and remote processing, but not rendering. (Ref: http://forums.cgsociety.org/showpost.php?p=4870718&postcount=10)

xsibatch -script -render


By combining -script and -render, you can use a script to set up a scene for rendering. xsibatch loads the scene, runs the script, and then does the render.
Any changes made by the script are not saved.

You can also use -script with -export flag. For example, if you wanted to change the output folder for .mi files, you could do this:

xsibatch -processing -export \\server\share\xsiDB\Scenes\test.scn
-script tmpChangeOutputDir.js -frames 1-5 -pass all

where the .js file changes Passes.RenderOptions.OutputDir to the desired output location.