[Bf-blender-cvs] [c86a4b82c23] usd-importer-T81257-merge: USD Import: Light Intensity Scale option.

makowalski noreply at git.blender.org
Tue Mar 9 04:07:53 CET 2021


Commit: c86a4b82c23378cabed1396830a723bc231e6764
Author: makowalski
Date:   Mon Mar 8 20:53:34 2021 -0500
Branches: usd-importer-T81257-merge
https://developer.blender.org/rBc86a4b82c23378cabed1396830a723bc231e6764

USD Import:  Light Intensity Scale option.

Added new float import option to scale intensity of imported
lights.

===================================================================

M	source/blender/editors/io/io_usd.c
M	source/blender/io/usd/intern/usd_reader_light.cc
M	source/blender/io/usd/usd.h

===================================================================

diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c
index 5b8604fe03d..9de29fbf007 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -318,6 +318,8 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
 
   const bool convert_to_z_up = RNA_boolean_get(op->ptr, "convert_to_z_up");
 
+  const float light_intensity_scale = RNA_float_get(op->ptr, "light_intensity_scale");
+
   int offset = 0;
   int sequence_len = 1;
 
@@ -336,34 +338,33 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
     ED_object_mode_set(C, OB_MODE_EDIT);
   }
 
-  struct USDImportParams params = {
-      scale,
-      vel_scale,
-      is_sequence,
-      set_frame_range,
-      sequence_len,
-      offset,
-      validate_meshes,
-      global_read_flag,
-      import_cameras,
-      import_curves,
-      import_lights,
-      import_materials,
-      import_meshes,
-      import_volumes,
-      prim_path_mask,
-      import_subdiv,
-      import_instance_proxies,
-      create_collection,
-      import_guide,
-      import_proxy,
-      import_render,
-      import_visible_only,
-      use_instancing,
-      import_usd_preview,
-      set_material_blend,
-      convert_to_z_up,
-  };
+  struct USDImportParams params = {scale,
+                                   vel_scale,
+                                   is_sequence,
+                                   set_frame_range,
+                                   sequence_len,
+                                   offset,
+                                   validate_meshes,
+                                   global_read_flag,
+                                   import_cameras,
+                                   import_curves,
+                                   import_lights,
+                                   import_materials,
+                                   import_meshes,
+                                   import_volumes,
+                                   prim_path_mask,
+                                   import_subdiv,
+                                   import_instance_proxies,
+                                   create_collection,
+                                   import_guide,
+                                   import_proxy,
+                                   import_render,
+                                   import_visible_only,
+                                   use_instancing,
+                                   import_usd_preview,
+                                   set_material_blend,
+                                   convert_to_z_up,
+                                   light_intensity_scale};
 
   bool ok = USD_import(C, filename, &params, as_background_job);
 
@@ -426,6 +427,9 @@ static void wm_usd_import_draw(bContext *UNUSED(C), wmOperator *op)
   row = uiLayoutRow(box, false);
   uiItemR(row, ptr, "convert_to_z_up", 0, NULL, ICON_NONE);
 
+  row = uiLayoutRow(box, false);
+  uiItemR(row, ptr, "light_intensity_scale", 0, NULL, ICON_NONE);
+
   // row = uiLayoutRow(box, false);
   // uiItemR(row, ptr, "prim_path_mask", 0, NULL, ICON_NONE);
 
@@ -628,6 +632,16 @@ void WM_OT_usd_import(struct wmOperatorType *ot)
                   "Convert to Z Up",
                   "When checked and if the USD stage up-axis is Y, apply a rotation "
                   "to the imported objects to convert their orientation to Z up ");
+
+  RNA_def_float(ot->srna,
+                "light_intensity_scale",
+                1.0f,
+                0.0001f,
+                10000.0f,
+                "Light Intensity Scale",
+                "Value by which to scale the intensity of imported lights",
+                0.0001f,
+                1000.0f);
 }
 
 #endif /* WITH_USD */
diff --git a/source/blender/io/usd/intern/usd_reader_light.cc b/source/blender/io/usd/intern/usd_reader_light.cc
index f0665d170a4..d15b2086fb8 100644
--- a/source/blender/io/usd/intern/usd_reader_light.cc
+++ b/source/blender/io/usd/intern/usd_reader_light.cc
@@ -99,8 +99,7 @@ void USDLightReader::readObjectData(Main *bmain, double motionSampleTime)
   pxr::VtValue intensity;
   light_prim.GetIntensityAttr().Get(&intensity, motionSampleTime);
 
-
-  blight->energy = intensity.Get<float>();
+  blight->energy = intensity.Get<float>() * this->m_import_params.light_intensity_scale;
 
   // TODO: Not currently supported
   // pxr::VtValue exposure;
diff --git a/source/blender/io/usd/usd.h b/source/blender/io/usd/usd.h
index 3e41f9653cd..2cf62e7cbff 100644
--- a/source/blender/io/usd/usd.h
+++ b/source/blender/io/usd/usd.h
@@ -71,6 +71,7 @@ struct USDImportParams {
   bool import_usd_preview;
   bool set_material_blend;
   bool convert_to_z_up;
+  float light_intensity_scale;
 };
 
 /* The USD_export takes a as_background_job parameter, and returns a boolean.



More information about the Bf-blender-cvs mailing list