Mantra command line arguments and IFD

   11526   11   1
User Avatar
Member
21 posts
Joined: Dec. 2012
Offline
Hi all,

I'm hoping someone can tell me if the following is possible:

I've got a sequence of IFD files (of a cloudy sky) that I want to submit as a Mantra render via Deadline. The Deadline submitter allows the user to specify command line arguments - I want to be able to set certain items in the IFD file as visible or not visible thru the command line so that I don't have to create a new IFD sequence for each “take”.

To make it clearer, as the Mantra engine consumes each IFD file in my sequence, I want to tell Mantra to hide Geo1 or show Geo2. Then with the same IFD sequence, I want to render a second pass but this time hide Geo2 and show Geo1.

I know I could break this up into takes and generate more than one IFD sequence but because I'm creating IFDs of volumes it takes a while to generate the IFDs and they're pretty hefty in terms of file size.

If this sounds possible, any command line examples you can share would be greatly appreciated! I saw this page (http://www.sidefx.com/docs/houdini13.0/render/batch) [sidefx.com] but I don't see any commands for “phantom” or “forceobject”.
User Avatar
Member
85 posts
Joined: Aug. 2010
Offline
You can use ifd filters by passing a script to mantra with the -P flag

here is an example script from a while back that contains functions to swap out the render filename using search strings (also making the directories that it needs and setting the pixel samples and resolution)

*CAVEAT* - I authored that file in H12 and havent had a chance to test it in 13 - just use it as a guide

import os, errno, mantra

newRes =
samples =

searchString = ‘oldSearchString’
replaceString = ‘newSearchString’

versionSearchString = ‘v001’
versionReplaceString = ‘v002’

def filterCamera():
filename = mantra.property('image:filename')
newfilename = filename.replace(searchString, replaceString).replace(versionSearchString, versionReplaceString)

folder = ‘/’.join(newfilename.split('/'))

if not os.path.exists(folder):
try:
os.makedirs(str(folder))
except OSError, e:
if e.errno == errno.EEXIST:
pass
else:
raise Exception(“Failed to create directory ” + folder + “: error %d” % e.errno)

mantra.setproperty('image:filename',newfilename)
mantra.setproperty('image:resolution', newRes)
mantra.setproperty('image:samples', samples)


I'll dig out the relevant docs to get you going and see if I can find the relevant code for hiding/unhiding
Edited by - June 11, 2014 07:43:00
Sam Swift-Glasman
Art Director
Five AI
User Avatar
Member
85 posts
Joined: Aug. 2010
Offline
http://www.sidefx.com/docs/houdini13.0/render/python [sidefx.com]

contains the relevant docs

You will need to create a function called filterInstance()
in which you will be able to change object settings to hide/unhide objects

will provide an example when I get a bit more time

-EDIT-

http://www.sidefx.com/docs/houdini13.0/props/mantra [sidefx.com]

The above contains a list of properties you can change on objects

i believe the best fit for hiding/unhiding would be to set the object as renderable or not using for the following property from the docs:


Houdini name vm_renderable
IFD name object:renderable
If this option is turned off, then the instance will not be rendered. The object’s properties can still be queried from within VEX, but no geometry will be rendered. This is roughly equivalent to turning the object into a transform space object.
Sam Swift-Glasman
Art Director
Five AI
User Avatar
Member
21 posts
Joined: Dec. 2012
Offline
glassman3d
i believe the best fit for hiding/unhiding would be to set the object as renderable or not using for the following property from the docs:

Houdini name vm_renderable
IFD name object:renderable

What a help, thanks glassman3d! I had seen that Properties page (should have mentioned it) but how to assemble the bits into a snippet of code is what's tripping me up. Not sure if you're familiar with Deadline but the Mantra entry window for addition commands is one line, so it appears I'd be limited in terms of what I can add to the submission window.
User Avatar
Member
85 posts
Joined: Aug. 2010
Offline
hi NYU_Animation

sorry I should have been more specific

You can call this command by saving the above in a python file called say “myFilters.py” then you can call

mantra -P myFilters.py - as your one line command in Deadline

are you familiar with python?
Sam Swift-Glasman
Art Director
Five AI
User Avatar
Member
21 posts
Joined: Dec. 2012
Offline
glassman3d
You can call this command by saving the above in a python file called say “myFilters.py” then you can call

mantra -P myFilters.py - as your one line command in Deadline

are you familiar with python?

Thank you again! I'm certainly no Python expert, but I think I'm getting the gist of how your script works. I'll use it in tandem with the Python page you pointed out earlier and will see if I can cobble something together.

Thanks!
User Avatar
Member
21 posts
Joined: Dec. 2012
Offline
This is the simple snippet I came up with (thanks to your code!) but it's not quite there…

import os, errno, mantra

def filterGeometry():
mantra.setproperty('object:renderable', “/obj/geo1”, “0”)

but I get the error
RuntimeError: mantra: Expected 2 arguments for ‘setproperty’

This is getting me closer
import os, errno, mantra

def filterGeometry():
geo = “/obj/geo1”
mantra.setproperty('object:renderable', 0)

It hides ALL the geometry (cooking with gas now!).

The final piece, then, is how to make this “apply” to just the geo1 node.
User Avatar
Member
85 posts
Joined: Aug. 2010
Offline
I think this may help (untested):

if mantra.property('object:name') == “/obj/geo1”:
mantra.setproperty('object:renderable', 0)

mantra runs filter instance over every object so you need to filter by the mantra render property:

'object:name'


hope that helps!
Sam Swift-Glasman
Art Director
Five AI
User Avatar
Member
21 posts
Joined: Dec. 2012
Offline
Hi Glassman3d, I just heard back from SESI and they suggested this:

import mantra

def filterInstance():
name = mantra.property('object:name')
if name == ‘/obj/grid_object1’:
mantra.setproperty('renderable', 0)

… which makes sense now that I see it.

Thanks for all your help!!

*EDIT* Anyone wanting to pass additional commands along through the Deadline Mantra submission script, don't start the command with “mantra”, start it with the first argument. Mine looks like

-P //Server/MainDirectory/pythonScript.py
User Avatar
Member
85 posts
Joined: Aug. 2010
Offline
Excellent - glad you got it going!

looks like mantra.property('object:name') is returning a list or tuple hence having to use an index

if your object is called /obj/grid_object1, my previous example would become:

if mantra.property('object:name') == “/obj/grid_object1”:
mantra.setproperty('object:renderable', 0)

this ifd hacking can be incredibly useful!
Sam Swift-Glasman
Art Director
Five AI
User Avatar
Member
260 posts
Joined: July 2006
Offline
wow this is a very good thread.

But can I ask you why you would not use Delayed Load Shaders for generating small IFDs.

Are you manipulating your volumes after the cache.
Head of CG @ MPC
CG Supervisor/ Sr. FX TD /
https://gumroad.com/timvfx [gumroad.com]
www.timucinozger.com
User Avatar
Member
85 posts
Joined: Aug. 2010
Offline
tricecold
wow this is a very good thread.

But can I ask you why you would not use Delayed Load Shaders for generating small IFDs.

Are you manipulating your volumes after the cache.

That is a really good point!

Apologies in my haste to answer the question about python filtering, I missed the main problem. IFD generation in most cases can be brought to a negligible gen time!
Sam Swift-Glasman
Art Director
Five AI
  • Quick Links