USD mesh sequence cache modifier doesn't update material indices #104683

Open
Michael Kowalski wants to merge 1 commits from makowalski/blender:usd-mesh-sequence-mtl-update into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

This pull request has been ported from patch http://developer.blender.org/D14087.

Fixed issue where the USD mesh reader invoked by the mesh sequence cache modifier does
not update material face sets when reading animating USD meshes with changing topology.

  • No longer checking the USD import parameters import_materials option to determine
    whether to read the face sets, since that flag is always value-initialized to false
    when the USD mesh reader is instantiated for the mesh sequence cache modifier.

  • Added a new MOD_MESHSEQ_READ_MAT_FACE_SETS enum for enabling reading material face
    sets. This flag is currently only used by the USD mesh reader (since the Alembic mesh
    importer always reads material face sets by default).

  • Added a read_mat_face_sets RNA property definition to the modifier to allow
    setting this flag in scripts.

To test: Load the attached animating_mtl_subsets.usd, which contains an animated mesh with changing topology and two materials assigned to geom subsets. Without this fix, the second material is lost after the first frame. With this fix, both materials are correctly assigned when playing all the frames.

This pull request has been ported from patch http://developer.blender.org/D14087. Fixed issue where the USD mesh reader invoked by the mesh sequence cache modifier does not update material face sets when reading animating USD meshes with changing topology. - No longer checking the USD import parameters import_materials option to determine whether to read the face sets, since that flag is always value-initialized to false when the USD mesh reader is instantiated for the mesh sequence cache modifier. - Added a new `MOD_MESHSEQ_READ_MAT_FACE_SETS` enum for enabling reading material face sets. This flag is currently only used by the USD mesh reader (since the Alembic mesh importer always reads material face sets by default). - Added a `read_mat_face_sets` RNA property definition to the modifier to allow setting this flag in scripts. **To test**: Load the attached `animating_mtl_subsets.usd`, which contains an animated mesh with changing topology and two materials assigned to geom subsets. Without this fix, the second material is lost after the first frame. With this fix, both materials are correctly assigned when playing all the frames.
Michael Kowalski added 1 commit 2023-02-13 04:11:57 +01:00
Fixed issue where the USD mesh reader invoked by the mesh sequence cache modifier does
not update material face sets when reading animating USD meshes with changing topology.

- No longer checking the USD import parameters import_materials option to determine
whether to read the face sets, since that flag is always value-initialized to false
when the USD mesh reader is instantiated for the mesh sequence cache modifier.

- Added a new MOD_MESHSEQ_READ_MAT_FACE_SETS enum for enabling reading material face
sets. This flag is currently only used by the USD mesh reader (since the Alembic mesh
importer always reads material face sets by default).

- Added an "read_mat_face_sets" RNA property definition to the modifier to allow
setting this flag in scripts.
Michael Kowalski added the
Interest
Pipeline, Assets & IO
Interest
USD
labels 2023-02-13 04:13:56 +01:00
Michael Kowalski requested review from Sybren A. Stüvel 2023-02-13 04:14:24 +01:00
Michael Kowalski requested review from Bastien Montagne 2023-02-13 04:14:25 +01:00
Author
Member

@mont29 This has the latest updates per your requests in https://archive.blender.org/developer/D14087

The only remaining question is whether an update to do_version is actually needed, per your last comment. I believe this might not be necessary, but please correct me if I misunderstood the issue.

@mont29 This has the latest updates per your requests in https://archive.blender.org/developer/D14087 The only remaining question is whether an update to `do_version` is actually needed, per your last comment. I believe this might not be necessary, but please correct me if I misunderstood the issue.
Brecht Van Lommel added this to the USD project 2023-02-13 08:42:02 +01:00

No longer checking the USD import parameters import_materials option to determine
whether to read the face sets

Is this describing a problem (like "even though it was set at import time, the modifier is no longer checking...") or is this a description of what the patch is doing ("originally the modifier checked the import_materials option, but it is no longer checking that now")?

On a higher level, what would be the impact of always loading these face sets? Is there a practical benefit of not loading this data? Does it significantly impact performance?

And as a final (if admittedly somewhat rhetorical) question: is there a design task where there is an outline of which mesh data is considered optional and which will always be loaded? I think having such a design discussion would be nice, as then we can have a clear overview of the kinds of mesh data we're talking about, and can make Blender behave consistently across different file types.

> No longer checking the USD import parameters import_materials option to determine whether to read the face sets Is this describing a problem (like "even though it was set at import time, the modifier is no longer checking...") or is this a description of what the patch is doing ("originally the modifier checked the `import_materials` option, but it is no longer checking that now")? On a higher level, what would be the impact of always loading these face sets? Is there a practical benefit of not loading this data? Does it significantly impact performance? And as a final (if admittedly somewhat rhetorical) question: is there a design task where there is an outline of which mesh data is considered optional and which will always be loaded? I think having such a design discussion would be nice, as then we can have a clear overview of the kinds of mesh data we're talking about, and can make Blender behave consistently across different file types.
Hans Goudey changed title from USD mesh sequence cache modifier doesn't update material indices. to USD mesh sequence cache modifier doesn't update material indices 2023-02-16 21:21:54 +01:00
Author
Member

My apologies for the delayed reply.

Is this describing a problem (like "even though it was set at import time, the modifier is no longer checking...") or is this a description of what the patch is doing ("originally the modifier checked the import_materials option, but it is no longer checking that now")?

This is a description of what the patch is currently doing, i.e., that the modifier is no longer checking the import_materials option.

On a higher level, what would be the impact of always loading these face sets? Is there a practical benefit of not loading this data? Does it significantly impact performance?

It's hard to generalize about the performance impact of always loading face sets. Loading face sets requires computing bound materials per mesh, so the performance would depend on the number of meshes and materials and possibly also on the complexity of the USD composition. However, the optimization in this patch would only apply when reading materials is turned off, which is probably a less common use case.

And as a final (if admittedly somewhat rhetorical) question: is there a design task where there is an outline of which mesh data is considered optional and which will always be loaded? I think having such a design discussion would be nice, as then we can have a clear overview of the kinds of mesh data we're talking about, and can make Blender behave consistently across different file types.

There was no design task for this. Would you like me to keep this patch on hold pending such a discussion?

My apologies for the delayed reply. > Is this describing a problem (like "even though it was set at import time, the modifier is no longer checking...") or is this a description of what the patch is doing ("originally the modifier checked the `import_materials` option, but it is no longer checking that now")? > This is a description of what the patch is currently doing, i.e., that the modifier is no longer checking the `import_materials` option. > On a higher level, what would be the impact of always loading these face sets? Is there a practical benefit of not loading this data? Does it significantly impact performance? > It's hard to generalize about the performance impact of always loading face sets. Loading face sets requires computing bound materials per mesh, so the performance would depend on the number of meshes and materials and possibly also on the complexity of the USD composition. However, the optimization in this patch would only apply when reading materials is turned off, which is probably a less common use case. > And as a final (if admittedly somewhat rhetorical) question: is there a design task where there is an outline of which mesh data is considered optional and which will always be loaded? I think having such a design discussion would be nice, as then we can have a clear overview of the kinds of mesh data we're talking about, and can make Blender behave consistently across different file types. > There was no design task for this. Would you like me to keep this patch on hold pending such a discussion?
Sybren A. Stüvel added
Module
Pipeline, Assets & IO
and removed
Interest
Pipeline, Assets & IO
labels 2023-04-18 10:29:48 +02:00

There was no design task for this. Would you like me to keep this patch on hold pending such a discussion?

The reason I'm asking is to get a better understanding of this choice:

No longer checking the USD import parameters import_materials option to determine whether to read the face sets, since that flag is always value-initialized to false when the USD mesh reader is instantiated for the mesh sequence cache modifier.

Another hypothetical solution for this would be to always properly initialise the import_materials flag, depending on what was chosen at import time (and maybe make it an option that can be toggled on the CacheFile datablock). After all, when you import without materials, why should they all of a sudden be imported when the mesh topology changes?

Maybe there's a good reason to do this, but this reasoning is not available in the PR description. Because of this, I think it's a good idea to discuss & agree upon such designs first, before looking at the code changes that might be necessary.

Without such explicit motivation for such choices, we'll no doubt have to deal with bug reports later, when Blender's behaviour isn't understood and considered a bug. If there is no explanation as to why it was implemented this way, it will be significantly harder to consistently answer such reports.

> There was no design task for this. Would you like me to keep this patch on hold pending such a discussion? The reason I'm asking is to get a better understanding of this choice: > No longer checking the USD import parameters import_materials option to determine whether to read the face sets, since that flag is always value-initialized to false when the USD mesh reader is instantiated for the mesh sequence cache modifier. Another hypothetical solution for this would be to always properly initialise the `import_materials` flag, depending on what was chosen at import time (and maybe make it an option that can be toggled on the `CacheFile` datablock). After all, when you import without materials, why should they all of a sudden be imported when the mesh topology changes? Maybe there's a good reason to do this, but this reasoning is not available in the PR description. Because of this, I think it's a good idea to discuss & agree upon such designs first, before looking at the code changes that might be necessary. Without such explicit motivation for such choices, we'll no doubt have to deal with bug reports later, when Blender's behaviour isn't understood and considered a bug. If there is no explanation as to *why* it was implemented this way, it will be significantly harder to consistently answer such reports.
This pull request has changes conflicting with the target branch.
  • source/blender/editors/io/io_usd.c
  • source/blender/io/usd/intern/usd_reader_mesh.cc
  • source/blender/makesdna/DNA_modifier_types.h
  • source/blender/makesrna/intern/rna_modifier.c

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u usd-mesh-sequence-mtl-update:makowalski-usd-mesh-sequence-mtl-update
git checkout makowalski-usd-mesh-sequence-mtl-update
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
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
Asset Browser Project
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
2 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#104683
No description provided.