Fix #110021: Deform modifier binding can go wrong in certain stacks #110095

Merged
Philipp Oeser merged 5 commits from lichtwerk/blender:110021 into main 2023-07-17 09:31:54 +02:00
Member

This affected Mesh Deform, Corrective Smooth and Laplacian Smooth.

Exposed by 57ea827bfb (e5ec04d73c).

Evaluating the incoming mesh can be different in
BKE_object_handle_data_update as opposed to
object_force_modifier_update_for_bind due to different
CustomData_MeshMasks being used (the former used a handpicked set, the
later was still using CD_MASK_BAREMESH). But since moving many
relevant [to modifiers] data to attributes, this could lead to binding go
wrong (e.g. reporting a vertex count mismatch as reported in #110021
which was due to the fact that creases were not propagated and that
changed the output [also vertex count] of a subdivision modifier in the
stack).

Now use CD_MASK_DERIVEDMESH in object_force_modifier_update_for_bind
to get all relevant attributes for evaluation (this is not used in BKE_object_handle_data_update
to avoid a big performance impact there).

Also fixes #109626 afaict.

Should probably go into 3.6 LTS (maybe even 3.3 LTS).

This affected `Mesh Deform`, `Corrective Smooth` and `Laplacian Smooth`. Exposed by 57ea827bfb (e5ec04d73c78). Evaluating the incoming mesh can be different in `BKE_object_handle_data_update` as opposed to `object_force_modifier_update_for_bind` due to different `CustomData_MeshMasks` being used (the former used a handpicked set, the later was still using `CD_MASK_BAREMESH`). But since moving many relevant [to modifiers] data to attributes, this could lead to binding go wrong (e.g. reporting a vertex count mismatch as reported in #110021 which was due to the fact that creases were not propagated and that changed the output [also vertex count] of a subdivision modifier in the stack). Now use `CD_MASK_DERIVEDMESH` in `object_force_modifier_update_for_bind` to get all relevant attributes for evaluation (this is not used in `BKE_object_handle_data_update` to avoid a big performance impact there). Also fixes #109626 afaict. Should probably go into 3.6 LTS (maybe even 3.3 LTS).
Philipp Oeser added 1 commit 2023-07-14 11:28:14 +02:00
f4fc03a07e Fix #110021: Deform modifier binding can go wrong in certain stacks.
This affected `Mesh Deform`, `Corrective Smooth` and `Laplacian Smooth`.

Exposed by 57ea827bfb (e5ec04d73c).

Evaluating the incoming mesh can be different in
`BKE_object_handle_data_update` as opposed to
`object_force_modifier_update_for_bind` due to different
`CustomData_MeshMasks` being used (the former uses the full set, the
later was still using `CD_MASK_BAREMESH`). But since moving many
relevant [to modifiers] data to attributes, this could lead to binding go
wrong (e.g. reporting a vertex count mismatch as reported in #110021
which was due to the fact that creases were not propagated and that
changed the output [also vertex count] of a subdivision modifier in the
stack).

Now use the same set of `CustomData_MeshMasks` in both places.

Also fixes #109626 afaict.

Should probably go into 3.6 LTS (maybe even 3.3 LTS).
Philipp Oeser added this to the Modeling project 2023-07-14 11:28:29 +02:00
Philipp Oeser added the
Interest
Modifiers
Interest
Animation & Rigging
labels 2023-07-14 11:28:51 +02:00
Philipp Oeser requested review from Brecht Van Lommel 2023-07-14 11:29:16 +02:00
Philipp Oeser requested review from Hans Goudey 2023-07-14 11:29:23 +02:00
Brecht Van Lommel requested changes 2023-07-14 12:21:27 +02:00
Brecht Van Lommel left a comment
Owner

Can we have a CD_MASK_EVAL_VIEWPORT and CD_MASK_EVAL_RENDER or something like that, to ensure these stay in sync?

Can we have a `CD_MASK_EVAL_VIEWPORT` and `CD_MASK_EVAL_RENDER` or something like that, to ensure these stay in sync?
Author
Member

Can we have a CD_MASK_EVAL_VIEWPORT and CD_MASK_EVAL_RENDER or something like that, to ensure these stay in sync?

Not sure about those names (not deep enough into this to really make an educated call), how about CD_MASK_EVAL_ATTRIBUTES (seems closer to what it does on first sight?)

> Can we have a `CD_MASK_EVAL_VIEWPORT` and `CD_MASK_EVAL_RENDER` or something like that, to ensure these stay in sync? Not sure about those names (not deep enough into this to really make an educated call), how about `CD_MASK_EVAL_ATTRIBUTES` (seems closer to what it does on first sight?)
Member

Ah, I see the issue now, thanks!

Can we have a CD_MASK_EVAL_VIEWPORT and CD_MASK_EVAL_RENDER or something like that, to ensure these stay in sync?

Or maybe we could just use CD_MASK_DERIVEDMESH here and avoid the complexity of adding masks manually?

Ah, I see the issue now, thanks! > Can we have a `CD_MASK_EVAL_VIEWPORT` and `CD_MASK_EVAL_RENDER` or something like that, to ensure these stay in sync? Or maybe we could just use `CD_MASK_DERIVEDMESH` here and avoid the complexity of adding masks manually?
Author
Member

CD_MASK_DERIVEDMESH is looking like it does a lot of things, since we want to have them in sync, this would need to be used in BKE_object_handle_data_update isnt this performance-critical? [I assume we dont need CD_MASK_PAINT_MASK or CD_MASK_PREVIEW_MLOOPCOL or stuff like that here?]

`CD_MASK_DERIVEDMESH` is looking like it does a lot of things, since we want to have them in sync, this would need to be used in `BKE_object_handle_data_update` isnt this performance-critical? [I assume we dont need `CD_MASK_PAINT_MASK` or `CD_MASK_PREVIEW_MLOOPCOL` or stuff like that here?]

Can we have a CD_MASK_EVAL_VIEWPORT and CD_MASK_EVAL_RENDER or something like that, to ensure these stay in sync?

Not sure about those names (not deep enough into this to really make an educated call), how about CD_MASK_EVAL_ATTRIBUTES (seems closer to what it does on first sight?)

I suggested CD_MASK_EVAL_VIEWPORT because it is the mask used for viewport evaluation of objects. It's about the purpose rather than its contents. Binding needs the same attributes as viewport evaluation.

Or maybe we could just use CD_MASK_DERIVEDMESH here and avoid the complexity of adding masks manually?

I guess that's fine too and not a real performance problem. Retrieving the mesh for binding doesn't have to be that fast.

> > Can we have a `CD_MASK_EVAL_VIEWPORT` and `CD_MASK_EVAL_RENDER` or something like that, to ensure these stay in sync? > > Not sure about those names (not deep enough into this to really make an educated call), how about `CD_MASK_EVAL_ATTRIBUTES` (seems closer to what it does on first sight?) I suggested `CD_MASK_EVAL_VIEWPORT` because it is the mask used for viewport evaluation of objects. It's about the purpose rather than its contents. Binding needs the same attributes as viewport evaluation. > Or maybe we could just use CD_MASK_DERIVEDMESH here and avoid the complexity of adding masks manually? I guess that's fine too and not a real performance problem. Retrieving the mesh for binding doesn't have to be that fast.
Member

CD_MASK_DERIVEDMESH is looking like it does a lot of things, since we want to have them in sync, this would need to be used in BKE_object_handle_data_update isnt this performance-critical? [I assume we dont need CD_MASK_PAINT_MASK or CD_MASK_PREVIEW_MLOOPCOL or stuff like that here?]

We're getting into edge case territory. Not propagating unused attributes isn't really an optimization we can rely on in the near future anyway, since things are becoming generic and the evaluated state of objects is becoming more visible. And like Brecht says, this isn't performance critical.

> `CD_MASK_DERIVEDMESH` is looking like it does a lot of things, since we want to have them in sync, this would need to be used in `BKE_object_handle_data_update` isnt this performance-critical? [I assume we dont need `CD_MASK_PAINT_MASK` or `CD_MASK_PREVIEW_MLOOPCOL` or stuff like that here?] We're getting into edge case territory. Not propagating unused attributes isn't really an optimization we can rely on in the near future anyway, since things are becoming generic and the evaluated state of objects is becoming more visible. And like Brecht says, this isn't performance critical.
Philipp Oeser added 2 commits 2023-07-15 14:07:56 +02:00
ba17baf0f1 use `CD_MASK_DERIVEDMESH` for customdata masks
this is now used in both `BKE_object_handle_data_update` and
`object_force_modifier_update_for_bind`

>Retrieving the mesh for binding doesn't have to be that fast.

note again that in order to have this consistent, `CD_MASK_DERIVEDMESH`
is now used in `BKE_object_handle_data_update` (depsgraph update) as
well, not just in binding!
Author
Member

Made the changes.

Retrieving the mesh for binding doesn't have to be that fast.

note again that in order to have this consistent, CD_MASK_DERIVEDMESH is now used in BKE_object_handle_data_update (depsgraph update) as well, not just in binding!

Made the changes. >Retrieving the mesh for binding doesn't have to be that fast. note again that in order to have this consistent, `CD_MASK_DERIVEDMESH` is now used in `BKE_object_handle_data_update` (depsgraph update) as well, not just in binding!
Philipp Oeser requested review from Brecht Van Lommel 2023-07-15 14:12:02 +02:00
Brecht Van Lommel requested changes 2023-07-15 14:13:59 +02:00
Brecht Van Lommel left a comment
Owner

BKE_object_handle_data_update should not be changed, doing it there will have a big performance impact.

`BKE_object_handle_data_update` should not be changed, doing it there will have a big performance impact.
Author
Member

CD_MASK_DERIVEDMESH is looking like it does a lot of things, since we want to have them in sync, this would need to be used in BKE_object_handle_data_update isnt this performance-critical? [I assume we dont need CD_MASK_PAINT_MASK or CD_MASK_PREVIEW_MLOOPCOL or stuff like that here?]

BKE_object_handle_data_update should not be changed, doing it there will have a big performance impact.

This is what I meant in my previous comment.
OK, will change back (in BKE_object_handle_data_update), so this will not really be in sync in these two places then, but at least we get the full set in binding, should be no harm I guess...

> `CD_MASK_DERIVEDMESH` is looking like it does a lot of things, since we want to have them in sync, this would need to be used in `BKE_object_handle_data_update` isnt this performance-critical? [I assume we dont need `CD_MASK_PAINT_MASK` or `CD_MASK_PREVIEW_MLOOPCOL` or stuff like that here?] >BKE_object_handle_data_update should not be changed, doing it there will have a big performance impact. This is what I meant in my previous comment. OK, will change back (in `BKE_object_handle_data_update`), so this will not really be in sync in these two places then, but at least we get the full set in binding, should be no harm I guess...
Philipp Oeser added 1 commit 2023-07-15 14:24:20 +02:00
Philipp Oeser added 1 commit 2023-07-15 14:27:26 +02:00
Philipp Oeser requested review from Brecht Van Lommel 2023-07-15 14:30:16 +02:00
Hans Goudey approved these changes 2023-07-16 05:11:44 +02:00
Hans Goudey changed title from Fix #110021: Deform modifier binding can go wrong in certain stacks. to Fix #110021: Deform modifier binding can go wrong in certain stacks 2023-07-16 05:12:01 +02:00
Philipp Oeser merged commit 2cb9290012 into main 2023-07-17 09:31:54 +02:00
Philipp Oeser deleted branch 110021 2023-07-17 09:31:58 +02:00
Brecht Van Lommel approved these changes 2023-07-17 20:16:26 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
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#110095
No description provided.