-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
usdMtlx ignores an active file prefix #974
Comments
Filed as internal issue #USD-5571 |
We've recently encountered this same issue. This ticket remains open, however the related ticket #977 was closed w/o the change being merged. Is there any particular reason why? I have a fix that I can polish up and contribute ; however I wanted to make sure I understand the complete history. |
Just to help demonstrate that this is still an issue as of 23.08, I adapted @willmuto-lucasfilm 's original reproduction code for python3, and made it self-contained (ie, no need to download anything else): import os
import tempfile
from pxr import Sdf, Usd, UsdShade
mtlx_contents = """\
<?xml version="1.0"?>
<materialx version="1.36">
<nodedef name="ND_layerShader" type="surfaceshader" node="layerShader">
<input name="in" type="filename"/>
</nodedef>
<material name="noPrefix">
<shaderref name="layered_sr" node="layerShader">
<bindinput name="in" type="filename" value="img1.jpg"/>
</shaderref>
</material>
<material name="prefixInValue">
<shaderref name="layered_sr" node="layerShader">
<bindinput name="in" type="filename" value="images/img2.jpg"/>
</shaderref>
</material>
<material name="prefixInAttr" fileprefix="images">
<shaderref name="layered_sr" node="layerShader">
<bindinput name="in" type="filename" value="img2.jpg"/>
</shaderref>
</material>
</materialx>"""
with tempfile.TemporaryDirectory() as tempdir:
os.chdir(tempdir)
# create the necessary files
mtlx_path = "ExpandFilePrefix.mtlx"
with open(mtlx_path, "w") as writer:
writer.write(mtlx_contents)
stage = Usd.Stage.CreateInMemory()
stage = stage.Open(mtlx_path)
for mat_path, expected_img in [
("/MaterialX/Materials/noPrefix", "img1.jpg"),
("/MaterialX/Materials/prefixInValue", "images/img2.jpg"),
("/MaterialX/Materials/prefixInAttr", "images/img2.jpg"),
]:
material = UsdShade.Material.Get(stage, mat_path)
input = material.GetInput("in")
actual_img = input.Get().path
print(actual_img)
if actual_img != expected_img:
print(f" !!!! Expected: {expected_img} !!!!") This outputs:
|
Hi @pmolodo @Derek-Nvidia , my apologies for the confusion here! Back when I originally submitted the PR there was some restructuring of the project and from what I remember I was going to open a new PR after the rebase which is why the related ticket was closed. I never got around to sorting this out after I wrapped my show at the time and went on holiday after, and it fell off my radar. I can dust off the change #977 or if you have a change ready to roll @Derek-Nvidia please feel free to use that. Again, my apologies! |
Hi, |
Material-X: flatten filenames upon read #974 (Internal change: 2301054)
Description of Issue
usdMtlx ignores an active file prefix defined by the fileprefix attribute in a parent tag.
Steps to Reproduce
And running the following python code:
Returns the following results:
This fix ensures that the fileprefix attribute is respected:
I have a fix which I will be submitting a pull request for shortly!
System Information (OS, Hardware)
Linux RHEL7
Package Versions
Build Flags
The text was updated successfully, but these errors were encountered: