Material Stylesheets and Attributes

   3603   4   1
User Avatar
Staff
4169 posts
Joined: Sept. 2007
Offline
I've got some packed prims, and I want to use their @map attribute to set the shader's baseColorMap either uvgrid_grey.pic, uvgrid_color.pic, or Mandril.pic. The sphere on the right shows the idea I'm trying to implement.

Is there a way to do this? I haven't been able to figure it out from the docs and examples, so if any MSS gurus have some tips, I'd greatly appreciate it!

{
“styles” :[
{
“target”: { “name” : “*”},
“overrides” : { “materialParameters”: {
“baseColorMap”: “@map”}}
}
]
}

Attachments:
screenshot-area-2015-05-28-212338.png (86.0 KB)
stylesheet_attributes.hipnc (1.1 MB)

I'm o.d.d.
User Avatar
Staff
4441 posts
Joined: July 2005
Offline
First, you should create the map attribute as a primitive attribute instead of a point attribute.

Second, the only way to bind a primitive attribute to a material parameter is through a cvex script. So set the style sheet to:


{
“styles” :[
{
“target”: { “name” : “*” },
“overrides” : {
“materialParameters”: {
“baseColorMap”: {
“script” : {
“code” : “cvex myFn(string map=\”\“; export string out_map=\”\“) { out_map = map; }”,
“bindings” : { “map” : “map” }
}
}
}
}
}
]
}
User Avatar
Staff
4169 posts
Joined: Sept. 2007
Offline
I see, I got tripped up when reading the docs; since you can pass something like “@Cd.r > 0.5” to the target, I assumed you could read attrs directly.

Thank you kindly sir!

Attachments:
screenshot-area-2015-05-28-234749.png (95.4 KB)

I'm o.d.d.
User Avatar
Member
1755 posts
Joined: March 2014
Offline
Interesting. What does this allow you to do in practical terms? Assign different shaders/textures for the pieces of a shattered ball?

edit: alright, thanks fir the answer goldleaf
(didn't want to bump the thread just for this)
Edited by - May 29, 2015 14:53:28
User Avatar
Staff
4169 posts
Joined: Sept. 2007
Offline
McNistor
Interesting. What does this allow you to do in practical terms? Assign different shaders/textures for the pieces of a shattered ball?

The shattered sphere was just a quick way to demonstrate the type of scenario I was trying to work in, without being able to share the alembic cache; this sort of things is probably more useful for Crowds or lighting Alembic scenes, where you don't want to load everything as Geometry in order to bind materials. I wanted to see if I could setup an attribute in a Python SOP, basic on the object's name, to setup the texture maps properly.
I'm o.d.d.
  • Quick Links