Fix: USD: Traverse through UsdShadeNodeGraph nodes during material import

Follow connections through `UsdShadeNodeGraph` nodes when reading
materials rather than looking only for `UsdShadeShader` nodes.

Found while investigating the Intel Sponza research sample:
https://www.intel.com/content/www/us/en/developer/topic-technology/graphics-research/samples.html

Pull Request: https://projects.blender.org/blender/blender/pulls/140565
This commit is contained in:
Jesse Yurkovich
2025-06-18 20:25:29 +02:00
committed by Jesse Yurkovich
parent a7f9ad5af6
commit bcd5af34f9
3 changed files with 142 additions and 5 deletions

View File

@@ -533,6 +533,17 @@ class USDImportTest(AbstractUSDTest):
assert_attribute(mat, "f_vec", "Vector", "Normal")
assert_attribute(mat, "f_float", "Fac", "Roughness")
def test_import_material_node_graph(self):
"""Verify we can follow connections through NodeGraph defs."""
testfile = str(self.testdir / "usd_materials_node_graph.usda")
res = bpy.ops.wm.usd_import(filepath=testfile)
self.assertEqual({'FINISHED'}, res)
# If NodeGraph traversal is missing or broken, the Image Texture and UV Map nodes will be missing
mat = bpy.data.materials["Material"]
self.assert_all_nodes_present(mat, ["Principled BSDF", "Image Texture", "UV Map", "Material Output"])
def test_import_shader_varname_with_connection(self):
"""Test importing USD shader where uv primvar is a connection"""