USD import: 'preview' purpose material fallback

Added logic to explicitly query bound materials
with purpose 'preview', if querying 'allPurpse' bound
materials returns no result.
This commit is contained in:
Michael Kowalski 2021-08-31 15:49:11 -04:00
parent 2e32a0871f
commit 182443da4b
Notes: blender-bot 2023-02-14 04:56:36 +01:00
Referenced by issue #90535, USDPreviewSurface materials in Animal Logic's ALab are missing textures
1 changed files with 13 additions and 1 deletions

View File

@ -723,6 +723,11 @@ void USDMeshReader::assign_facesets_to_mpoly(double motionSampleTime,
pxr::UsdShadeMaterial subset_mtl = subset_api.ComputeBoundMaterial();
if (!subset_mtl) {
/* Check for a preview material as fallback. */
subset_mtl = subset_api.ComputeBoundMaterial(pxr::UsdShadeTokens->preview);
}
if (!subset_mtl) {
continue;
}
@ -753,7 +758,14 @@ void USDMeshReader::assign_facesets_to_mpoly(double motionSampleTime,
if (r_mat_map->empty()) {
pxr::UsdShadeMaterialBindingAPI api = pxr::UsdShadeMaterialBindingAPI(prim_);
if (pxr::UsdShadeMaterial mtl = api.ComputeBoundMaterial()) {
pxr::UsdShadeMaterial mtl = api.ComputeBoundMaterial();
if (!mtl) {
/* Check for a preview material as fallback. */
mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->preview);
}
if (mtl) {
pxr::SdfPath mtl_path = mtl.GetPath();