Migrating USD paths from Windows to Linux?

   2832   19   3
User Avatar
Member
433 posts
Joined: April 2018
Offline
Is there a convenient way to change asset paths when exporting a final USD scene for command line rendering? I work in Windows and sometimes render in Linux on Azure. I have identical folder structures, C:\projects\tex for example turns into /home/brian/projects/tex so it's just a matter of replacing the first part of the path. For small things it's not a big deal, but for a big project it would be nice to automate this within Houdini. Thanks!
Subscribe to my Patreon for the best CG tips, tricks and tutorials! https://patreon.com/bhgc [patreon.com]

Twitter: https://twitter.com/brianhanke [twitter.com]
Behance: https://www.behance.net/brianhanke/projects [www.behance.net]
User Avatar
Member
7770 posts
Joined: Sept. 2011
Offline
BrianHanke
Is there a convenient way to change asset paths when exporting a final USD scene for command line rendering? I work in Windows and sometimes render in Linux on Azure. I have identical folder structures, C:\projects\tex for example turns into /home/brian/projects/tex so it's just a matter of replacing the first part of the path. For small things it's not a big deal, but for a big project it would be nice to automate this within Houdini. Thanks!

The best way is to only use relative paths. That way it can be portable to any system wholesale, and all references should resolve regardless of the location of the root asset folder. A sticking point would be generated asset paths--the rendered images. Houdini is setup to use absolute paths for render products, and I'm not sure if relative paths are supported. I believe husk can run some python preprocess on the usd before rendering--this should allow for repathing the output products.

https://www.sidefx.com/docs/houdini/ref/utils/husk.html#usd [www.sidefx.com]
User Avatar
Staff
4438 posts
Joined: July 2005
Offline
First rule is to use relative paths if at all possible. Then you don't need to worry about this at all.

H19 has a "Modify Paths" LOP which is good for this sort of task, as long as it is "asset" paths you want to update (texture files, volume files). The Modify Paths LOP does not currently alter USD paths (sublayers, references, payloads). There is an RFE for this, but maybe even in its current state it would be useful for you?
User Avatar
Staff
4164 posts
Joined: Sept. 2007
Offline
Modify Paths LOP [www.sidefx.com] may be what you need, for fixing texture paths and other @assetpath@ attributes.

You can also use the Relative Paths output processor on the USD ROP, as that'll help avoid this problem in the future by not hard-coding absolute paths in the first place.

HTH!
I'm o.d.d.
User Avatar
Staff
4164 posts
Joined: Sept. 2007
Offline
Ha, Mark beat me to it
I'm o.d.d.
User Avatar
Staff
4164 posts
Joined: Sept. 2007
Offline
And jsmack too!
I'm o.d.d.
User Avatar
Member
7770 posts
Joined: Sept. 2011
Offline
mtucker
First rule is to use relative paths if at all possible. Then you don't need to worry about this at all.

H19 has a "Modify Paths" LOP which is good for this sort of task, as long as it is "asset" paths you want to update (texture files, volume files). The Modify Paths LOP does not currently alter USD paths (sublayers, references, payloads). There is an RFE for this, but maybe even in its current state it would be useful for you?

Mark, can render products also be specified with relative paths?
User Avatar
Member
433 posts
Joined: April 2018
Offline
Ha, thanks everybody! Modify Paths looks perfect, should be just what I need!
Subscribe to my Patreon for the best CG tips, tricks and tutorials! https://patreon.com/bhgc [patreon.com]

Twitter: https://twitter.com/brianhanke [twitter.com]
Behance: https://www.behance.net/brianhanke/projects [www.behance.net]
User Avatar
Member
273 posts
Joined: Nov. 2013
Offline
A related question so I'll ask here - by relative are we talking about prefixed with $HIP, or a true relative path? If the later, is there a way to stop the houdini file pickers from prefixing everything with $HIP?
User Avatar
Member
7770 posts
Joined: Sept. 2011
Offline
antc
A related question so I'll ask here - by relative are we talking about prefixed with $HIP, or a true relative path? If the later, is there a way to stop the houdini file pickers from prefixing everything with $HIP?

We're talking about USD relative paths, which are like unix relative paths but are relative to the layer they are written to not the cwd of the process. When building the scene in lops, you can specify relative paths directly if you use the right output processor for it, but because the layers don't actually exist at those locations yet, the scene won't work correctly interactively. The better way is to use absolute paths when building the scene, and use the relative path output processor to convert them when writing the stage. This way, you can use $HIP in the paths if your output will be in $HIP.
User Avatar
Staff
4438 posts
Joined: July 2005
Offline
jsmack
Mark, can render products also be specified with relative paths?

They can be, but I think the RenderProduct "produc name" attribute (which is where the file path gets put) is a string attribute, not an "asset" attribute (not 100% sure why). Which means it is not affected by Output Processors run on the USD ROP. So in this one case, you probably want to set the Product Name parameter to a relative path. This path will probably (unlike a proper asset USD attribute) be interpreted as relative to the directory from which husk is being run, or maybe the directory containing the root USD file being rendered by husk.

As a rule (with this one exception of the Product Name), jsmack is right that you should use absolute paths in file path parameters in LOPs (and using $HIP in the path ensures the parameter will evaluate to an absolute path). Let the "Make Relative Paths" output processor on the USD ROP work out the details.
User Avatar
Member
273 posts
Joined: Nov. 2013
Offline
jsmack
antc
A related question so I'll ask here - by relative are we talking about prefixed with $HIP, or a true relative path? If the later, is there a way to stop the houdini file pickers from prefixing everything with $HIP?

We're talking about USD relative paths, which are like unix relative paths but are relative to the layer they are written to not the cwd of the process. When building the scene in lops, you can specify relative paths directly if you use the right output processor for it, but because the layers don't actually exist at those locations yet, the scene won't work correctly interactively. The better way is to use absolute paths when building the scene, and use the relative path output processor to convert them when writing the stage. This way, you can use $HIP in the paths if your output will be in $HIP.

Thanks for clarifying jsmack. A (slightly off topic) follow up questions then - is the $HIP substitution that happens in file pickers etc special cased or is there a more general mechanism recognizing and substituting environment variables in paths? For example imagine a texture library that's on a different mount or drive. Would it be possible to have the file picker replace e.g "E:\textures" with "$TEXLIB" automatically?
Edited by antc - Nov. 3, 2021 21:18:44
User Avatar
Member
59 posts
Joined: Nov. 2017
Offline
With relative paths, what do we do with multiple roots?
User Avatar
Member
273 posts
Joined: Nov. 2013
Offline
HristoVelev
With relative paths, what do we do with multiple roots?
A relative sublayer (or reference) path is relative to the layer the path is authored, which may or may not be a root layer it doesn't matter. Therefore two layers in different locations would have different relative paths to some other shared file.
User Avatar
Member
59 posts
Joined: Nov. 2017
Offline
Sorry, I meant file system roots In our case the renders and geometries are in different servers and mapped to different roots for example.
User Avatar
Member
23 posts
Joined: Oct. 2018
Offline
I have different machines using different paths, one windows and one linux.

I've set up a couple of specific variables for where things should go that use the same naming:
For instance $CACHE goes to E:/localcache on Win and /mnt/md0/localcache on Linux (both internal raids, but do the same job).

I have various variables that lead to $HDR, $MODEL_LIBRARY, $TEX etc that point to specific server locations, but formatted for Win and Linux respectively.
User Avatar
Member
59 posts
Joined: Nov. 2017
Offline
We're now doing something similar, but these would still end up as absolute and not relative paths in the USD, right? When one file needs to define a relative path to another file which is on a different root, can't do that? I guess in the linux paths it's possible, but maybe not on the Win paths?
User Avatar
Member
273 posts
Joined: Nov. 2013
Offline
Kind of the long/complicated answer is that USD uses asset resolver plugins to resolve paths and that would be one way to deal with multiple platforms. I’m not sure though if Houdini’s version of USD ships with the default resolver enabled.

The USD default resolver allows for a set of ‘search paths’ to be set via the PXR_AR_DEFAULT_SEARCH_PATH environment variable. So you could structure your paths in USD like e.g Geometry/MyAsset.usd which looks like a relative path but will actually be ‘searched’ using the directories specified in the envvar. So by setting the envvar differently on windows and linux the same paths will get resolved to different locations. On windows the envvar might include C:/Project in turn resolving to C:/Project/Geometry/MyAsset.usd while on linux /Project thus resolving to /Project/Geometry/MyAsset.usd

Note that true relative paths in USD typically start with ./ as a way to differentiate from search paths.

Like I said though I’m not sure if Houdini has the default resolver enabled out-the-box.
Edited by antc - Jan. 19, 2024 10:00:34
User Avatar
Member
59 posts
Joined: Nov. 2017
Offline
Search paths sounds promising, I'll try that! We'll be looking at a custom resolver too.
User Avatar
Member
59 posts
Joined: Nov. 2017
Offline
Turns our all it takes is relative paths and UNC names in windows - with the root being just a branch in the UNC path, relative paths work
  • Quick Links