Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kowalski <makowalski@nvidia.com>2021-11-19 21:48:02 +0300
committerMichael Kowalski <makowalski@nvidia.com>2021-11-19 21:48:02 +0300
commit05c4982f712be287b901713e6d8cfc0cbc208696 (patch)
tree169a052f41038c1d7e9bd4ea68ae64537ca64300 /source/blender/editors/io/io_usd.c
parent4c988eb3e144712b98fddc97b2e669e88a23eaa8 (diff)
USD Preview Surface material import improvements.
Updates to address issues importing USD Preview Surface materials in Animal Logic's ALab scene, as described in T90535: Added support for importing UDIM textures. Added 'Material Name Collision' USD import menu option, to specify the behavior when USD materials in different namespaces have the same name. The options are Modify: Create a unique name for the imported material. Skip: Keep the existing material and discard the imported material. Previously, the default behavior was Skip. This was causing an issue in the Alab scene, where dozens of different USD materials all have the same name 'usdpreviewsurface1', so that only one instance of these materials would be imported. Finally, if no materials with purpose "render" are assigned to the USD primitive, the importer will now fall back on converting assigned materials with purpose "preview".
Diffstat (limited to 'source/blender/editors/io/io_usd.c')
-rw-r--r--source/blender/editors/io/io_usd.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c
index 4e2ccea36ab..39f09014a61 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -73,6 +73,20 @@ const EnumPropertyItem rna_enum_usd_export_evaluation_mode_items[] = {
{0, NULL, 0, NULL, NULL},
};
+const EnumPropertyItem rna_enum_usd_mtl_name_collision_mode_items[] = {
+ {USD_MTL_NAME_COLLISION_MODIFY,
+ "MODIFY",
+ 0,
+ "Modify",
+ "Create a unique name for the imported material"},
+ {USD_MTL_NAME_COLLISION_SKIP,
+ "SKIP",
+ 0,
+ "Skip",
+ "Keep the existing material and discard the imported material"},
+ {0, NULL, 0, NULL, NULL},
+};
+
/* Stored in the wmOperator's customdata field to indicate it should run as a background job.
* This is set when the operator is invoked, and not set when it is only executed. */
enum { AS_BACKGROUND_JOB = 1 };
@@ -318,6 +332,9 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
const float light_intensity_scale = RNA_float_get(op->ptr, "light_intensity_scale");
+ const eUSDMtlNameCollisionMode mtl_name_collision_mode = RNA_enum_get(op->ptr,
+ "mtl_name_collision_mode");
+
/* TODO(makowalski): Add support for sequences. */
const bool is_sequence = false;
int offset = 0;
@@ -356,7 +373,8 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
.use_instancing = use_instancing,
.import_usd_preview = import_usd_preview,
.set_material_blend = set_material_blend,
- .light_intensity_scale = light_intensity_scale};
+ .light_intensity_scale = light_intensity_scale,
+ .mtl_name_collision_mode = mtl_name_collision_mode};
const bool ok = USD_import(C, filename, &params, as_background_job);
@@ -399,6 +417,7 @@ static void wm_usd_import_draw(bContext *UNUSED(C), wmOperator *op)
uiItemR(col, ptr, "relative_path", 0, NULL, ICON_NONE);
uiItemR(col, ptr, "create_collection", 0, NULL, ICON_NONE);
uiItemR(box, ptr, "light_intensity_scale", 0, NULL, ICON_NONE);
+ uiItemR(box, ptr, "mtl_name_collision_mode", 0, NULL, ICON_NONE);
box = uiLayoutBox(layout);
col = uiLayoutColumnWithHeading(box, true, IFACE_("Experimental"));
@@ -519,6 +538,13 @@ void WM_OT_usd_import(struct wmOperatorType *ot)
"Scale for the intensity of imported lights",
0.0001f,
1000.0f);
+
+ RNA_def_enum(ot->srna,
+ "mtl_name_collision_mode",
+ rna_enum_usd_mtl_name_collision_mode_items,
+ USD_MTL_NAME_COLLISION_MODIFY,
+ "Material Name Collision",
+ "Behavior when the name of an imported material conflicts with an existing material");
}
#endif /* WITH_USD */