Autodesk / arnold-usd

Arnold components for USD
https://www.arnoldrenderer.com/
Other
236 stars 56 forks source link

Make arnold relative path optional in image nodes #1879

Closed sebastienblor closed 3 months ago

sebastienblor commented 3 months ago

Changes proposed in this pull request When usd data is authored from an image shader, we add a boolean custom metadata "arnold_relative_path" to the filename attribute.

When reading the usd data, this will tell arnold to use the filename as-is, without any additional hack for relative paths & udims. But without this flag, the behaviour will be the same as for UvTexture shaders.

I'm updating test_1546 that now needs this metadata to work properly. Also adding test_1878 which is identical to test_0225 but with an arnold:image shader instead of UvTexture.

EDIT: I'm extending this PR to handle all asset attributes instead of having a white list of shaders & attributes to support. Whatever the attribute is, we will look for the eventual metadata to skip the path remapping logic

Issues fixed in this pull request Fixes #1878 Fixes #1881

Additional context Add any other context or screenshots about the pull request here.

sebastienblor commented 3 months ago

Since we don't need to have a special default logic for the arnold image shaders anymore, we can now make the behaviour for udim & relative paths more generic. This will also address Roy's point about materialx shaders for #1881, and will work for the different mtlx texture shaders (ND_image, ND_tiledimage , ND_triplanarprojection*)

So now, every time we read an asset parameter, we first ask USD to resolve it. If it fails to do so, that the path is relative, and that the metadata "arnold_relative_path" is NOT enabled, then we go through the logic of remapping the relative path ourselves.

Since arnold image shaders are now authored with this metadata, when we read them back, we will have the expected roundtrip. Note that we could also use the metadata on other shader types (UvTexture, mtlx textures, etc...) but in practice it wouldn't make much sense.

I'm adding test_1881 that has the same scene as test_0225 & test_1878, but with a Mtlx image shader.

BigRoy commented 3 months ago

So now, every time we read an asset parameter, we first ask USD to resolve it. If it fails to do so

Is this entirely true? Wouldn't a relative path, when USD tries to resolve it have USD anchor it to the USD layer the opinion is in. Technically there could be a relative file there with the same name, but the arnold_relative_path metadata still being authored to a different search path. In this scenario would the path still be picked from the USD resolving or the one from the arnold_relative_path.

If this is a scenario where we only want to use the arnold_relative_path if file is not found relatively by USD then we might want to clarify maybe that it's a "fallback" only and not an override?