Model- AND material-variants on one asset possible?

   2684   8   1
User Avatar
Member
33 posts
Joined: March 2012
Offline
Hey all,

I am currently trying to wrap my head around variants in USD, and I would like to know if there is a way to have model- and material-variants both on one asset? (“Nested” variants?)

For example, I want to have an asset that consists of different shapes and materials (colors).

possible shape (variants): cube, sphere
possible material (variants): red, blue, green

In the end, I would like to choose something like “cube” “red”, or “cube” “green”, or “sphere” “blue”.

In the file attached, I tried to somehow “nest” the variants. My cube and sphere both have material variants (red or green), and those feed into another add-variant LOP that switches between the two (shapes with shader variants). In order to make it work I need to add a lot of groups ontop of the assets which “hold” the variants. It works techically, but it feels cluttered and not really like the way to go.

As an alternative, I thought about creating every possible combination of shape and material as variant, but having just 3-4 shapes + 3-4 colors as material will quickly increase the number of variants to an uncomfortably high number.

I could of course create an asset for each shape that only has shading variants, but I am wondering (for experimenting purposes) if what I describe above can be achieved in an elegant way?

Thanks in advance for your time and help!

Attachments:
shape_and_material_variants_test.hipnc (304.9 KB)

www.scratch-arts.net
User Avatar
Staff
1448 posts
Joined: July 2005
Offline
Here is my attempt at that. See the attached .hipnc file.

Attachments:
shape_and_material_variants_example.hipnc (369.5 KB)

User Avatar
Member
33 posts
Joined: March 2012
Offline
Thanks a lot for your answer, that works brilliantly!

I would have another question regarding duplicate LOP (instance) and extract instance LOP if I may.

To learn and to test some workflows I have duplicated (instanced) a bunch of my variants from above using the duplicate LOP. The transform primitives of the duplicates appear light blue (instancable prim) and the geo/materials dark blue (Uneditable “instance proxy” prims under an Instanceable prim). So far so good (I think).

I then tried the extract instance LOP to convert one of the instance back to actual geo to do some edits (just as a workflow test) but couldnt get it to work. The node errors out with the following message:

Error 
Invalid source /stage/extractinstances1/pythonscript1
Warning: Ill-formed SdfPath </extractinstances1//instance_0>: syntax error
Error: Python error: Traceback (most recent call last):
File "<stdin>", line 5, in <module>
RuntimeError: Accessed <pxr.Usd.Object object at 0x00000000A0D5A9C8>

I'm sure I'm missing something / doing something wrong here. What would be the correct way of going about this?

Again thank you for your awesome support!

Attachments:
extract_instance_test.hipnc (335.0 KB)

www.scratch-arts.net
User Avatar
Staff
4435 posts
Joined: July 2005
Offline
Looks like there is a bug in extractinstances. I think it should be pretty easy to fix.
User Avatar
Staff
4435 posts
Joined: July 2005
Offline
I'll also point out that to take an existing native instnace and make it so that it is not an instance any more, you can just use a configure primitives LOP to set the “Instanceable” metadata on the primitive to false. Extract Instances is possibly overkill in this situation.
User Avatar
Member
33 posts
Joined: March 2012
Offline
mtucker
just use a configure primitives LOP to set the “Instanceable” metadata on the primitive to false.

That worked, thanks a lot for that handy tipp! I was so focussed on using the extract instance LOP that I forgot about that simple option.

I also just for fun tried to do the same using an attribute wrangle LOP:
usd_setmetadata(0, "/box_long_green_3", "instanceable", "False");
It did chang the metadata value when I inspected it, but didn't convert the instance for some reason. I guess that's not as simple as I assumed, but it does not matter actually. The configure primitives LOP works perfectly (and there is actually no reason to go for a wrangle). It was just out of pure curiosity.

Again thanks, you really helped me making progress here!
www.scratch-arts.net
User Avatar
Staff
1448 posts
Joined: July 2005
Offline
Scratch
It did chang the metadata value when I inspected it, but didn't convert the instance for some reason.
Just a shot in the dark, but perhaps the metadata type was `int` instead of `bool`, which USD may be expecting. There is an RFE to better support the type of metadata.
User Avatar
Staff
4435 posts
Joined: July 2005
Offline
Also, I'm told that the bug in extract instances has now been fixed.
User Avatar
Member
33 posts
Joined: March 2012
Offline
rafal
[perhaps the metadata type was `int` instead of `bool`, which USD may be expecting.

Thanks for your tipp! I tried int / float and string like this:

int my_value = 0;
usd_setmetadata(0, "/box_long_green_3", "instanceable", my_value);

and

float my_value = 0;
usd_setmetadata(0, "/box_long_green_3", "instanceable", my_value);

and

string my_value = "False";
usd_setmetadata(0, "/box_long_green_3", "instanceable", my_value);

and directly as bool (string?) like this:
usd_setmetadata(0, "/box_long_green_3", "instanceable", "False");

The meta data value always changes , but the scene-graph does not react to it and still shows an instance. Wrong code / function maybe? (But it's not that big of a deal if it does not work using a wrangle. I by no means want to annoy/bother you with such a trifle. Configure primitive LOP works perfectly, and the wrangle was just out of pure curiosity as I said earlier.)

mtucker
Also, I'm told that the bug in extract instances has now been fixed.
You guys just rock! Thanks!!
If anyone else is reading this, Houdini 18.0.509 and up has the bug fixed. (https://www.sidefx.com/changelog/)
Edited by Scratch - June 26, 2020 05:44:50
www.scratch-arts.net
  • Quick Links