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!
Model- AND material-variants on one asset possible?
3229 8 1- Scratch
- Member
- 33 posts
- Joined: 3月 2012
- Offline
- rafal
- スタッフ
- 1455 posts
- Joined: 7月 2005
- Offline
- Scratch
- Member
- 33 posts
- Joined: 3月 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:
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!
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!
- mtucker
- スタッフ
- 4525 posts
- Joined: 7月 2005
- Offline
- mtucker
- スタッフ
- 4525 posts
- Joined: 7月 2005
- Offline
- Scratch
- Member
- 33 posts
- Joined: 3月 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");
Again thanks, you really helped me making progress here!
- rafal
- スタッフ
- 1455 posts
- Joined: 7月 2005
- Offline
- mtucker
- スタッフ
- 4525 posts
- Joined: 7月 2005
- Offline
- Scratch
- Member
- 33 posts
- Joined: 3月 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.)
mtuckerYou guys just rock! Thanks!!
Also, I'm told that the bug in extract instances has now been fixed.
If anyone else is reading this, Houdini 18.0.509 and up has the bug fixed. (https://www.sidefx.com/changelog/)
Edited by Scratch - 2020年6月26日 05:44:50
-
- Quick Links