USD Modify Textures Path

   412   3   1
User Avatar
Member
33 posts
Joined: Feb. 2019
Offline
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
633 posts
Joined: Aug. 2014
Offline
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 - May 7, 2025 11:08:38

Attachments:
modify_texture_path.hiplc.zip (18.3 KB)

User Avatar
Member
19 posts
Joined: July 2014
Offline
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
319 posts
Joined:
Offline
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