optimizing batch rendering (avoiding scene reload / getting rendering state / on-the-fly frame deployment)

758 views
Skip to first unread message

Enrico Losavio

unread,
Dec 14, 2016, 7:18:25 AM12/14/16
to Python Programming for Autodesk Maya
Hi everyone,

I am struggling to optimize a batch rendering script of mine.
Basically I've wrote a script that assigns a certain number of frames to each computer in the studio, and then writes a batch render (bat) file per pc. 
In case of big scenes, the rendering is automatically split into 'chunks'. So that 10000 frames are broken down into -say- 500 frames, then divided and assigned to the computers. By doing so, we make sure that little by little we complete parts of the animation without having gaps in between.
The problem with this is that every time a line is executed, the scene and all the dependencies are reloaded. And this, in case of an heavy scene, could mean take minutes. Also, in case of small chunks / many batch lines, it might results in a huge loss of time.
What I am trying to do here, is to avoid the usual batch render, and to use another system. I want to open the scene, keep it open and render as many frames as I want. Also one at a time.

I also want to be able to catch the state/render log in real time, in order to monitor the render and see what's going on on all the computers.
Using the regular batch render, I can catch the exitcode, but that is only when the execution of the whole batch finishes.

For now I am just trying to get my script to be more flexible. But I'd say that the long term goal is to have the frames deployed one by one, monitor the render progress remotely, and as soon as one pc frees up, assign a new frame!

I am trying with mayapy, but I'm not making a great deal of a progress.
In this case, I want to render using VRay. The cmds module provides a render function, but that's only for rendering using MayaSoftware. 
In my code, I basically just open the file, set the workspace, load vray and render trying out a bunch of functions I've found digging deep inside the cmds module. 

import maya.standalone
maya.standalone.initialize()

import maya.cmds as cmds

filepath = r"C:\test_prj\rnd_test.mb"
cmds.file(filepath, open=True, force=True)

cmds.workspace(r"C:\test_prj", openWorkspace=True)

cmds.loadPlugin('vrayformaya')

# the following functions were called one by one in different test files, here's just a recap

cmds.batchRender() # Result: There is currently no render to cancel
cmds.BatchRender() # no result
cmds.render()      # renders just fine, but in MayaSoftware :(
cmds.vrend()       # V-Ray error: Cannot get the object for the current render layer:

But none of these options seem to work properly for me.
There's little to no documentation on the vray python commands, so it's a bit hard to debug what's goning on with the last command.

Can anyone suggest me which way to go? Do I have better options than MayaPy?
Any help would be greatly appreciated :)

Thanks

Enrico

David Moulder

unread,
Dec 14, 2016, 8:29:27 AM12/14/16
to python_inside_maya
Hi,

Try this

import maya.cmds as cmds
import maya.mel as mel
mel.eval("""setCurrentRenderer "arnold" """)

Cheers


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/91ce3f96-692d-4761-955a-6443ce185c0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Enrico Losavio

unread,
Dec 14, 2016, 10:08:02 AM12/14/16
to Python Programming for Autodesk Maya
Hi David,

thanks for your suggestion. I've just added your code, but yet nothing changed...

I've also added this bit of code to set only one camera renderable (I had it in another test script, but forgot to add it to the snippet in the previous post).

import maya.standalone
maya.standalone.initialize()

import maya.cmds as cmds
import maya.mel as mel

filepath = r"C:\test_prj\rnd_test.mb"
cmds.file(filepath, open=True, force=True)

cmds.workspace(r"C:\test_prj", openWorkspace=True)

# set only one camera renderable

render_cam_name = "render_cam"
cam_ls = cmds.ls(type="camera")
for cam in cam_ls:
    cmds.setAttr('{0}.renderable'.format(cam), False)
cmds.setAttr('{0}Shape.renderable'.format(render_cam_name), True)   

cmds.loadPlugin('vrayformaya')
mel.eval("""setCurrentRenderer "vray" """)

# the following functions were called one by one in different test files, here's just a recap

cmds.batchRender() # Result: There is currently no render to cancel
cmds.BatchRender() # no result
cmds.render()      # renders just fine, but in MayaSoftware :(
cmds.vrend()       # V-Ray error: Cannot get the object for the current render layer:

But still cannot get it to work. 

Please let me know if you've any idea!

Thanks.

David Moulder

unread,
Dec 14, 2016, 12:14:30 PM12/14/16
to python_inside_maya
Hi Enrico,

I've never used Vray but just found this web site
https://github.com/BigRoy/mayaVrayCommandDocs/wiki/vrend

From the looks of it you may need to associate the default render layer.  Hope this helps.

import maya.cmds as mc
currentLayer = mc.editRenderLayerGlobals(q=1, currentRenderLayer=True)
mc.vrend("-camera", "persp", "-layer", currentLayer)


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Enrico Losavio

unread,
Dec 14, 2016, 1:18:59 PM12/14/16
to Python Programming for Autodesk Maya
Oh hey!

Thanks, I've just come across this website as well. That finally makes it render!! yay!
Mel sintax was the answer all along!

It's good to have this documentation. Although the lack of an official documentation leaves it still wrapped in a mystery.
It's funny how they say that most of those flags seem not to have any effect at all :)
Actually the -layer flag is much needed in my case. Without it, the render wouldn't start.

So, now the good news is that it is rendering. I am setting all the rendering options with a setAttr on the defaultRenderGlobals (or the vraySettings).
Thing is -after a few tests- vray still exports a vray_scene for each frame. Thus loading in the memory all the dependencies, and unloading them right after the rendering is finished. Which is cool for a simple scene, but if I have lots of ploygons, and heavy textures (they can get up to 500mb each), this makes extremely unefficent. Also, vrend() doesn't return anything, so it's really hard to monitor what's going on. Maybe by reading the vray render log continuously and somehow interpreting the strings, but I'm sure there's a better way!

So, sadly I have to admit that I probably have to look somewhere else than the vrend() function.
I basically want to keep maya and vray up and running, ready to receive new frames to render, and I want to get some feedback.
Maybe this vrend() has some hidden non-documented flags that allow me to do what I want, but it's just a guess.

However, the game is still on. So if anyone has some feedback/suggestions... it's more than welcome :)

E.

David Moulder

unread,
Dec 14, 2016, 1:40:25 PM12/14/16
to python_inside_maya
I'm no rendering guru, but wouldn't vray standalone be the correct answer?

Just one thing I'm not clear on with your approach.  Are you rendering single frames from a bat file?  Are you not better off clumping the renders into buckets based on a ratio of render nodes to frames?  This would then stop the re-opening of files (network bottleneck) and then the re-translation of the file to the vray render format...  However, what you might be saying is that the Vray is wasting cycles translating everyframe in the render session.  Which sounds crazy for a render developer who should care about speed.

Not really any help, but good luck non the less.  It sounds like it could be a nightmare.

-Dave

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages