Hi is there any way using a attributeWrangle to know the names of the children of a Primitive? I would like to Store them into a String Array.
In my .usd, each mesh primitive comes with a PBR Preview Surface material and a few textures attached.
I want to know, for each mesh primitive the name of the texture file Path linked to their bound Materials.
So far I managed to get the name of the material prim linked to each mesh prim using usd_boundmaterialpath
But after this I am lost
The name of the texture seems to be stored in a Shader Primitive under the Material Primitive.
But this primitive has a name that changes with each prim (although it always starts with "texSampler_"), so I do not know what to do.
Any help is welcomed!
LOP attribWrangle: get children of a Primitive in VEX
1997 5 0- PaoloGiandoso
- Member
- 52 posts
- Joined: June 2020
- Offline
- mtucker
- Staff
- 4443 posts
- Joined: July 2005
- Offline
I think you are using VEX for things where there is a much easier solution... You should be able to find all the primitives you're interested in using a primitive pattern (https://www.sidefx.com/docs/houdini/solaris/pattern.html). Without doing any kind of checking, I would bet something like this might work:
%descendants(%matfromgeo([set of geo primitives on which you're running your VEX code]))
Edited by mtucker - Jan. 21, 2022 10:26:04
- mtucker
- Staff
- 4443 posts
- Joined: July 2005
- Offline
- PaoloGiandoso
- Member
- 52 posts
- Joined: June 2020
- Offline
mtucker
I think you are using VEX for things where there is a much easier solution... You should be able to find all the primitives you're interested in using a primitive pattern (https://www.sidefx.com/docs/houdini/solaris/pattern.html). Without doing any kind of checking, I would bet something like this might work:%descendants(%matfromgeo([set of geo primitives on which you're running your VEX code]))
If I understood it correctly, the primitive pattern would allow me to select the shader primitives,
but in my case I need to operate on the mesh primitives and extract the strings of the texture path connected to their PBR Preview Shader material (which come with the file).
My goal is assign a unique shader to all my mesh prims and have the texture variate per primitive. Like a per primitive material override in mantra. Therefore I need to find a way to know the texture paths linked to each mesh prim.
With usd_boundmaterialpath I can locate the material prim of a mesh prim, but after this I get stuck.
PaoloGiandosoSo weird that there is a find parent but not a find descendant function .
And to answer your original question, no, there is not currently a VEX function to get the children/descendants of a primitive.
Edited by PaoloGiandoso - Jan. 21, 2022 20:35:47
- rafal
- Staff
- 1449 posts
- Joined: July 2005
- Offline
PaoloGiandosoCorrect. From there you can traverse the ancestors to get back to the mesh primitives (or their parent if that's where the material binding has been authored). See attached .hip file.
f I understood it correctly, the primitive pattern would allow me to select the shader primitives,
Another way is to use Python LOP and use the USD API directly, instead of the Wrangle and the VEX. See the attached .hip file too.
PaoloGiandosoGood news is that it has been already added to the future 19.5 branch.
So weird that there is a find parent but not a find descendant function
- Cicuta
- Member
- 55 posts
- Joined: Nov. 2019
- Offline
rafal
Another way is to use Python LOP and use the USD API directly, instead of the Wrangle and the VEX. See the attached .hip file too.
Indeed python has more options than vex. However, when working with a big stage and iterating around a lot of primitves (200k, for example), you start to see that vex significantly faster than python. So beware of the performance hit.
-
- Quick Links