USD: dome light IO #121800

Merged
Michael Kowalski merged 19 commits from CharlesWardlaw/blender:feature/dome_light_and_other_upgrades into main 2024-05-30 20:48:54 +02:00

This commit adds logic to convert between USD dome lights and Blender
world materials.

The USD dome light rotation is represented in a mapping node input to the
environment texture. If the dome light has a color specified in addition to
the texture map, the color will be converted to a vector multiply on the
the environment texture output.

I the imported USD has multiple dome lights, only the first dome light will
be converted to a world material.

To test, download and unzip the attached suzanne_dome_light_test.zip
load the attached suzanne_with_environment.blend file, export to USD
and compare the results visually in USDView.

This commit adds logic to convert between USD dome lights and Blender world materials. The USD dome light rotation is represented in a mapping node input to the environment texture. If the dome light has a color specified in addition to the texture map, the color will be converted to a vector multiply on the the environment texture output. I the imported USD has multiple dome lights, only the first dome light will be converted to a world material. To test, download and unzip the attached `suzanne_dome_light_test.zip` load the attached `suzanne_with_environment.blend` file, export to USD and compare the results visually in USDView.
Charles Wardlaw added 1 commit 2024-05-14 20:40:12 +02:00
Charles Wardlaw requested review from Michael Kowalski 2024-05-14 20:40:29 +02:00
Michael Kowalski added 1 commit 2024-05-15 22:08:03 +02:00
0d5ec9a5d8 USD: remove non-essential features from PR
Removed options and functionality that can be submitted as
separate PRs.
Michael Kowalski added 1 commit 2024-05-15 22:50:52 +02:00
Michael Kowalski added 2 commits 2024-05-25 00:14:25 +02:00
Michael Kowalski added 1 commit 2024-05-25 00:47:32 +02:00
Michael Kowalski added 1 commit 2024-05-25 18:13:36 +02:00
Michael Kowalski added 5 commits 2024-05-27 02:55:51 +02:00
7e53617923 USD: cleanup and refactor domelight IO
Now creating a mapping node to set the environment texture
rotations.

No longer creating empties for dome lights on import, to reduce
clutter in the scene and reduce the chance of name collisions
for the dome light prims on export on round-trips.

Added logic to ensure the dome light paths are unique in the
scene.

Removed code that was not essential to dome lights to expedite
the review process.

Moved duplicated to code to separate functios.

General cleanup (e.g., replacing cerr/cout with CLOG).
Michael Kowalski added 3 commits 2024-05-27 03:36:07 +02:00
Michael Kowalski added 1 commit 2024-05-27 04:06:54 +02:00
Michael Kowalski added 1 commit 2024-05-29 15:29:29 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
df133acb8a
USD: fixed dome light rotation import/export

@blender-bot build

@blender-bot build
Michael Kowalski changed title from WIP: Usd I/O: Basic dome light support, ArResolver support, and light scale support. to WIP: Usd: dome light IO 2024-05-29 16:01:40 +02:00
Michael Kowalski changed title from WIP: Usd: dome light IO to Usd: dome light IO 2024-05-29 16:35:42 +02:00
Michael Kowalski changed title from Usd: dome light IO to USD: dome light IO 2024-05-29 16:35:54 +02:00
Michael Kowalski requested review from Jesse Yurkovich 2024-05-29 16:36:12 +02:00
Jesse Yurkovich requested changes 2024-05-29 22:18:06 +02:00
Dismissed
@ -1048,0 +1067,4 @@
true,
"Create Background Shader",
"Convert first discovered USD dome lights to world background shader");

I wouldn't use the terms "background" or "shader" in the UI or for the property names. Why not make it symmetric with the export side and use "Import World Material" or "Create World Material" if import is a slight misnomer?

I wouldn't use the terms "background" or "shader" in the UI or for the property names. Why not make it symmetric with the export side and use "Import World Material" or "Create World Material" if import is a slight misnomer?
makowalski marked this conversation as resolved
@ -0,0 +218,4 @@
(bNodeSocketValueRGBA *)((bNodeSocket *)BLI_findlink(&fromnode->inputs, 0))->default_value;
bNodeSocketValueFloat *strength_data = (bNodeSocketValueFloat *)((bNodeSocket *)BLI_findlink(
&fromnode->inputs, 1))
->default_value;

Use our typed APIs for accessing the node sockets like:

    bNodeSocketValueRGBA *color_data = bke::nodeFindSocket(fromnode, SOCK_IN, "Color")
                                           ->default_value_typed<bNodeSocketValueRGBA>();
    bNodeSocketValueFloat *strength_data = bke::nodeFindSocket(fromnode, SOCK_IN, "Strength")
                                               ->default_value_typed<bNodeSocketValueFloat>();
Use our typed APIs for accessing the node sockets like: ``` bNodeSocketValueRGBA *color_data = bke::nodeFindSocket(fromnode, SOCK_IN, "Color") ->default_value_typed<bNodeSocketValueRGBA>(); bNodeSocketValueFloat *strength_data = bke::nodeFindSocket(fromnode, SOCK_IN, "Strength") ->default_value_typed<bNodeSocketValueFloat>(); ```
makowalski marked this conversation as resolved
@ -0,0 +321,4 @@
dome_light.CreateIntensityAttr().Set(res.world_intensity);
}
if (res.mapping_found) {

Can we provide a default rotation in this case? I often don't use a mapping node so on export the HDRI is sideways. It's probably ok to just always use mapping_rot given its default of 0's anyways.

Can we provide a default rotation in this case? I often don't use a mapping node so on export the HDRI is sideways. It's probably ok to just always use `mapping_rot` given its default of 0's anyways.
makowalski marked this conversation as resolved
@ -0,0 +365,4 @@
if (!scene->world->nodetree) {
scene->world->nodetree = bke::ntreeAddTree(NULL, "Shader Nodetree", "ShaderNodeTree");
if (!scene->world->nodetree) {
CLOG_WARN(&LOG, "Couldn't create world ntree");

Should return from here if this is the case.

Should `return` from here if this is the case.
makowalski marked this conversation as resolved
@ -0,0 +417,4 @@
}
/* Make sure the first input to the shader node is disconnected. */
bNodeSocket *shader_input = static_cast<bNodeSocket *>(BLI_findlink(&bgshader->inputs, 0));

Use bke::nodeFindSocket(bgshader, SOCK_IN, "Color"); instead of BLI_findlink directly

Use `bke::nodeFindSocket(bgshader, SOCK_IN, "Color");` instead of BLI_findlink directly
makowalski marked this conversation as resolved
@ -227,2 +231,4 @@
return new USDMeshReader(prim, params_, settings_);
}
if (prim.IsA<pxr::UsdLuxDomeLight>()) {
/* We don't handle dome lights. */

It's probably better to say that the dome lights are handled elsewhere.

It's probably better to say that the dome lights are handled elsewhere.
makowalski marked this conversation as resolved
@ -43,1 +44,4 @@
/* USD dome lights are converted to a world material,
* rather than light objects, so are handled differently */
std::vector<pxr::UsdLuxDomeLight> dome_lights_;

Use blender::Vector

Use `blender::Vector`
makowalski marked this conversation as resolved
@ -112,6 +117,11 @@ class USDStageReader {
return readers_;
};
const std::vector<pxr::UsdLuxDomeLight> &dome_lights() const

Use blender::Vector

Use `blender::Vector`
makowalski marked this conversation as resolved
Jesse Yurkovich reviewed 2024-05-30 04:35:47 +02:00
@ -285,0 +282,4 @@
export_lights,
export_cameras,
export_curves,
export_volumes};

Keeping the trailing , on export_volumes will prevent this re-flow from happening.

Keeping the trailing `,` on export_volumes will prevent this re-flow from happening.
makowalski marked this conversation as resolved
Michael Kowalski added 1 commit 2024-05-30 18:44:44 +02:00

Thanks for the very helpful review, @deadpin! I believe I've addressed your comments.

Thanks for the very helpful review, @deadpin! I believe I've addressed your comments.
Jesse Yurkovich reviewed 2024-05-30 19:06:17 +02:00
@ -316,6 +319,8 @@ static void wm_usd_export_draw(bContext *C, wmOperator *op)
uiItemR(col, ptr, "export_normals", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "export_materials", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "export_custom_properties", UI_ITEM_NONE, nullptr, ICON_NONE);
uiItemR(col, ptr, "convert_world_material", UI_ITEM_NONE, nullptr, ICON_NONE);

Darn, I missed this the first time. The drawing of this property has to come after "author_blender_name" since that is related to, and is affected by, "export_custom_properties"

Darn, I missed this the first time. The drawing of this property has to come after "author_blender_name" since that is related to, and is affected by, "export_custom_properties"
makowalski marked this conversation as resolved
Michael Kowalski added 1 commit 2024-05-30 19:18:24 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
459a0268e4
USD: fixed convert_world_material option drawing

Good catch, @deadpin! The drawing order should be fixed now. Thanks!

Good catch, @deadpin! The drawing order should be fixed now. Thanks!
Jesse Yurkovich approved these changes 2024-05-30 19:21:43 +02:00
Jesse Yurkovich left a comment
Member

All good now!

All good now!

@blender-bot build

@blender-bot build

Thanks! I'll merge this a little later today.

Thanks! I'll merge this a little later today.
Michael Kowalski approved these changes 2024-05-30 19:59:13 +02:00
Michael Kowalski merged commit e1a6749b3d into main 2024-05-30 20:48:54 +02:00
Michael Kowalski referenced this issue from a commit 2024-05-30 20:48:55 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser Project (Legacy)
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#121800
No description provided.