USD Modify Textures Path

   930   3   1
User Avatar
Member
33 posts
Joined: 2月 2019
オンライン
I'm working between my two workstations, and I was wondering if there was a way to modify each textures absolute paths from my imported USD file.

Say on computer 1 my textures are on D:/work/projectFile/HoudiniProject/Tex
And on my computer 2 my textures are on G:/work/HoudiniProject/Tex

Is there a way to find and replace those paths? I've tried the USD Modify Path TOP node, the Modify Path LOP node, all without any success.. I'm probably not doing the right thing, still new in USD and learning the pipeline.


I'm slowly working on making all my projects files having the same hierachy between my worksatsions, but in a case where it's not possible, it'd be great to have a workaround for that.


Thank you!
User Avatar
Member
649 posts
Joined: 8月 2014
オフライン
Willbel2001
D:/work/projectFile/HoudiniProject/Tex
G:/work/HoudiniProject/Tex
If on both computers your textures are in project's directory ($HIPor $JOB), then you should be using relative paths to access them. This would save you from having to deal with the problem that you're currently experiencing.

Regarding Modify Path LOP, see the attached example in which I changed path prefix from /tmp/to /dev/shm/.
Edited by ajz3d - 2025年5月7日 11:08:38

Attachments:
modify_texture_path.hiplc.zip (18.3 KB)

User Avatar
Member
19 posts
Joined: 7月 2014
オフライン
You could also use variables in houdini.env for each computer eg

Computer 1:
TEXTURES = path/to/textures/on/computer1
Computer 2:
TEXTURES = path/to/textures/on/computer2

and access them with $TEXTURES in your scene.
User Avatar
Member
321 posts
Joined:
オンライン
In a LOP network you can use an Attribute Wrangle node to replace strings in your texture paths.

Assuming you are using MaterialX image prims as your texture inputs, on the wrangle you can set your "Primitives" parm to:

%descendants(%type(Material), strict=false)

and the VEX code like this:
if (usd_isattrib(0, s@primpath, "inputs:file"))
{
    string path = usd_attrib(0, s@primpath, "inputs:file");
    path = replace(path, "D:/work/projectFile/HoudiniProject/Tex", "G:/work/HoudiniProject/Tex");
    s@inputs:file = path;
}
  • Quick Links