Jump to content
timmwagener

[H12.5] Mantra PythonFiltering for global material overrides

Recommended Posts

Hi guys,

i'm new to the forum and Houdini, and i'm currently diving into Mantra (once again :D).

And what i would like to achieve is basically a global material override.(For AmbOcc for example)

What i tried so far:

1: Adding a shop_materialpath attr. to the subnetwork that is the toplevel node of my structure and overriding it on a take. (Much like Vray Object Property Sets in Maya for example, whose attributes ripple down on all members of the sets).....but that doesnt work i guess

2: Override the shop_materialpath on each geometry node which works fine and is much less a hustle than it sounds at first. But it still needs tweaking, once i add a new object to the scene.

3:PythonFiltering: Which seems like the way to go for me! From what ive read so far, the Houdini scene translation is written in Python and properties like shader assignments can be altered during the process.

So i read the documentation and did the following:

-Changed the mantra commandline to: mantra -P pythToMyScript/script.py

-In wrote the following script:


def filterInstance():
print('Filtering: {0}'.format(mantra.property('object:name')))
mantra.setproperty('object:surface', '/obj/shop_net/constant_green_mt')
mantra.setproperty('object:overridedetail', 1)
print('Im just an a output to confirm i have been called!')[/CODE]

-The script is actually called and i get the correct output in the console like so:

[CODE]Filtering: ['/obj/enzo_geo_grp/glassRubberGrp/black_behind_window_thing3']
Im just an a output to confirm i have been called![/CODE]

-But the last line states an error:

[CODE]
mantra: VEX error: Unable to load file /obj/shop_net/constant_green_mt.vex
Rendering Finished[/CODE]

-I added the declare_all_shops parameter to the mantra rop and set it to "Declare all shops" , also i checked on Force VEX Shader embedding

-Both materials are just ordinary constant mtls. i dragged into my own SHOP network in /obj/shop_net/.

Any ideas on what i am doing wrong here?

Thx

Share this post


Link to post
Share on other sites

Hi Timm, how are you doing?

Great to see you finally working with Mantra:)

After tinkering around a bit I came up with this:


import mantra

matDict = {}

def filterMaterial():
name = mantra.property('object:name')[0]
properties = mantra.property('object:surface')[0]
matDict[name] = properties

def filterInstance():
print('Filtering: {0}'.format(mantra.property('object:name')))
mantra.setproperty('object:surface', matDict['/obj/shopnet/clay'].split())
print(mantra.property('object:surface'))
[/CODE]

Tschoebi :D

Edited by dennis.weil

Share this post


Link to post
Share on other sites

Hey Dennis :D

Of course, i'm looking at Mantra and Houdini in general.

I quickly tried your example and it was throwing a key error. Might be something i'm doing wrong.

I currently use the joy of Houdini and Mantra as a relaxation, next to learning CPP,

but i'm looking forward to diving deeper into that.

Hope everything is "tutti" with u dudes (and Mrs.Lotte) in Wiesbaden ;)

Take care!

Share this post


Link to post
Share on other sites

Maybe you didn't change matDict['/obj/shopnet/clay'] to matDict['/obj/shop_net/constant_green_mt'] ?

If possible send me your example file so I can have a look at it.

Share this post


Link to post
Share on other sites

So, i just tinkered with it again, and now it works...(......it riali woerks!! :))

Problem just was that i hadnt saved the scene with the "declare_all_shops" parameter installed on the mantra node!

Thank you!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×