Assign material/color

   4363   5   1
User Avatar
Member
52 posts
Joined: March 2008
Offline
Excuse the primitive questions…

I am creating some geometry via a Python script. There, to make it visible, I am assigning an attribute and set it to an arbitrary color, like this:

bla.setAttribValue(“Cd”,(0.25,0.5,0.0)) #green

Then, in Houdini, I do not seem to be able to change this color or assign materials. I think they get assigned but without any visible result.

Can you please advise on how to do this properly. I am obviously doing something wrong here…

Thank you.
User Avatar
Member
52 posts
Joined: March 2008
Offline
Any advice on this? Basically, I need to know how to setup geometry via HDK in such a way so that it would be ready to be used in a normal way within GUI.

Even a pointer to the relevant place in documentation would be good.

Thanks again…
User Avatar
Member
7028 posts
Joined: July 2005
Offline
Hi Anna,

An attribute like Cd doesn't get picked up automatically unless you have a shader applied that uses it.

You can assign in the GUI via a Material SOP a shader, which really just adds a primitive string attribute to the geometry indicating what shader to use on those primitives. This could be easily duplicated in the HDK/Python as you're doing already with the Cd attribute.

Hope that helps!

Cheers,

Peter B
User Avatar
Member
52 posts
Joined: March 2008
Offline
Thanks. This worked. Now I have to understand how.
User Avatar
Member
7028 posts
Joined: July 2005
Offline
Well, briefly, when the IFD file is created in Houdini the attributes are parsed, and the appropriate shader is referenced so that Mantra knows which shader to apply to the geometry.

In the shader, there will be a Parameter VOP (assuming it's a standard Houdini Material) that creates VEX code that roughly looks like:

vector Cd = 0;

however if a 3float/vector attributes called Cd exists, it will completely replace this input per-point or primitive depending on if it's a point or prim attribute.

Hope that helps

Cheers,

Peter B
User Avatar
Member
52 posts
Joined: March 2008
Offline
Thanks. It does.
  • Quick Links