Fix #137973: Add MaterialX version info on USD export
This change adds MaterialX version information to the exported MaterialX USD materials. Details: In USD 25.02, the MaterialXConfigAPI schema was introduced to allow recording the MaterialX version used to author a material. When loading MaterialX documents into USD, this schema is automatically applied and the associated version attribute is created on the material. Due to how the MaterialX export works (via copying the composed MaterialX spec from a temporary stage), the MaterialXConfigAPI needs to be explicitly applied to the final material being exported. This change applies this MaterialXConfigAPI schema and copies the version attribute from the temporary MaterialX stage to the final stage. Authored by Apple: Dan Knowlton Co-authored-by: Dan Knowlton <d_knowlton@apple.com> Pull Request: https://projects.blender.org/blender/blender/pulls/137974
This commit is contained in:
committed by
Jesse Yurkovich
parent
2c99edbffa
commit
79c318f692
@@ -9,7 +9,7 @@ import pprint
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pxr import Gf, Sdf, Usd, UsdGeom, UsdShade, UsdSkel, UsdUtils, UsdVol
|
||||
from pxr import Gf, Sdf, Usd, UsdGeom, UsdMtlx, UsdShade, UsdSkel, UsdUtils, UsdVol
|
||||
|
||||
import bpy
|
||||
|
||||
@@ -1132,6 +1132,11 @@ class USDExportTest(AbstractUSDTest):
|
||||
material_prim = stage.GetPrimAtPath("/root/_materials/Material")
|
||||
self.assertTrue(material_prim, "Could not find Material prim")
|
||||
|
||||
self.assertTrue(material_prim.HasAPI(UsdMtlx.MaterialXConfigAPI))
|
||||
mtlx_config_api = UsdMtlx.MaterialXConfigAPI(material_prim)
|
||||
mtlx_version_attr = mtlx_config_api.GetConfigMtlxVersionAttr()
|
||||
self.assertTrue(mtlx_version_attr, "Could not find mtlx config version attribute")
|
||||
|
||||
material = UsdShade.Material(material_prim)
|
||||
mtlx_output = material.GetOutput("mtlx:surface")
|
||||
self.assertTrue(mtlx_output, "Could not find mtlx output")
|
||||
|
||||
Reference in New Issue
Block a user