[Bf-blender-cvs] [69c2c9de0ff] universal-scene-description: USD import: preview surface fallback.
Michael Kowalski
noreply at git.blender.org
Sat May 14 22:06:17 CEST 2022
Commit: 69c2c9de0ff6c68e8e4fdb554ad16eb1ec43af98
Author: Michael Kowalski
Date: Sat May 14 16:05:32 2022 -0400
Branches: universal-scene-description
https://developer.blender.org/rB69c2c9de0ff6c68e8e4fdb554ad16eb1ec43af98
USD import: preview surface fallback.
Added logic to fall back on importing USD Preview Surface
shaders, if possible, if importing MDL is specified but
an MDL couldn't be imported.
===================================================================
M source/blender/io/usd/intern/usd_reader_material.cc
===================================================================
diff --git a/source/blender/io/usd/intern/usd_reader_material.cc b/source/blender/io/usd/intern/usd_reader_material.cc
index 835a40db860..1ebd88cfbc4 100644
--- a/source/blender/io/usd/intern/usd_reader_material.cc
+++ b/source/blender/io/usd/intern/usd_reader_material.cc
@@ -392,12 +392,23 @@ Material *USDMaterialReader::add_material(const pxr::UsdShadeMaterial &usd_mater
bool has_mdl = false;
#ifdef WITH_PYTHON
/* Invoke UMM to convert to MDL. */
- umm_import_mdl_material(mtl, usd_material, true /* Verbose */, &has_mdl);
+ bool mdl_imported = umm_import_mdl_material(mtl, usd_material, true /* Verbose */, &has_mdl);
#endif
- if (!has_mdl && usd_preview) {
- /* The material has no MDL shader, so fall back on importing UsdPreviewSuface. */
- std::string message = "Material has no MDL shader " + mtl_name +
- ", importing USD Preview Surface shaders instead";
+ if (!(has_mdl && mdl_imported) && usd_preview) {
+ /* The material has no MDL shader or we couldn't convert the MDL,
+ * so fall back on importing UsdPreviewSuface. */
+ std::string message;
+
+ if (!has_mdl) {
+ message += "No MDL shader for material ";
+ }
+ else if (!mdl_imported) {
+ message += "Couldn't import MDL shader for material ";
+ }
+
+ message += mtl_name;
+ message += ", importing USD Preview Surface shaders instead";
+
WM_reportf(RPT_INFO, message.c_str());
import_usd_preview(mtl, usd_preview);
}
More information about the Bf-blender-cvs
mailing list