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:
authormakowalski <makowalski@nvidia.com>2021-03-09 04:53:34 +0300
committermakowalski <makowalski@nvidia.com>2021-03-09 04:53:34 +0300
commitc86a4b82c23378cabed1396830a723bc231e6764 (patch)
treef0c9aef511350ced5af74b11b9db57cf3ce97546
parent9bed12b3a42e3e7d066e0333952ca60ff3b5ab07 (diff)
USD Import: Light Intensity Scale option.
Added new float import option to scale intensity of imported lights.
-rw-r--r--source/blender/editors/io/io_usd.c70
-rw-r--r--source/blender/io/usd/intern/usd_reader_light.cc3
-rw-r--r--source/blender/io/usd/usd.h1
3 files changed, 44 insertions, 30 deletions
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.