USD import: Handle material purpose
This is a partial fix for T90535. USD allows binding materials generically as well as for a specific purpose. I.e., purpose may be generic (unspecified) or one of - Full: truest representation of the scene - Preview: lightweight material for preview Curently, only generically bound materials, with unspecified purpose (allPurpose), are imported. This issue is preventing preview materials from being imported in the Alab scene. This patch adds logic to attempt to fall back on importing preview or full materials, in that order, if there is no generic material bound to the mesh. Reviewed by: Sybren Differential Revision: https://developer.blender.org/D15352
This commit is contained in:
parent
99f2b59fe6
commit
0fade955dd
@ -64,7 +64,22 @@ static void build_mat_map(const Main *bmain, std::map<std::string, Material *> *
|
||||
|
||||
static pxr::UsdShadeMaterial compute_bound_material(const pxr::UsdPrim &prim)
|
||||
{
|
||||
return pxr::UsdShadeMaterialBindingAPI(prim).ComputeBoundMaterial();
|
||||
pxr::UsdShadeMaterialBindingAPI api = pxr::UsdShadeMaterialBindingAPI(prim);
|
||||
|
||||
/* Compute generically bound ('allPurpose') materials. */
|
||||
pxr::UsdShadeMaterial mtl = api.ComputeBoundMaterial();
|
||||
|
||||
/* If no generic material could be resolved, also check for 'preview' and
|
||||
* 'full' purpose materials as fallbacks. */
|
||||
if (!mtl) {
|
||||
mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->preview);
|
||||
}
|
||||
|
||||
if (!mtl) {
|
||||
mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->full);
|
||||
}
|
||||
|
||||
return mtl;
|
||||
}
|
||||
|
||||
/* Returns an existing Blender material that corresponds to the USD
|
||||
|
Loading…
Reference in New Issue
Block a user