Jump to content

[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

Link to comment
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
Link to comment
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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...