Mesh Sequence Cache (ABC) an hair interpolated children distribution issue (triangulate modifier seem to fix it) #92561

Closed
opened 2021-10-28 09:55:02 +02:00 by Carlo Andreacchio · 29 comments

System Information
Operating system: Ubuntu 20.04
Graphics card: GTX 1080

Blender Version
Broken: d7b231baa8

Short description of error
When applying a Mesh Sequence Cache (ABC) to a mesh with hair, does not respect the hair correctly. Mesh Cache (PC2) Works correctly.

The PC2 reacts the way I would have expected the object to react.
Exporting to USD also experiences the same issue as ABC.

The file has a few different objects in it, one has the original hair setup. One has an armature (with simple animation). One has this and the hair on it. One has a ABC mesh sequence cache applied to it (which is the issue). and one has a PC2 mesh cache applied to it (works fine)

Aim
We want our animators to animate, without hair on the armature, as this would slow down the file and increase file size.
Once animation is ready to light / render / comp, we want to bake out the animation to ABC, apply the mesh cache to the object with hair, and render that.

Exact steps for others to reproduce the error
bug_v001.blend
untitled.abc
untitled.pc2

  1. Download all attached blend files (Blend, ABC and PC2)
  2. toggle the viewport visibility of the Mesh Sequence Cache modifier on and off for the ABC Mesh Cache Object.
  3. Notice how the hair moves
  4. Click on the PC2 Mesh cache object (to the right)
  5. Repeat.
  6. Notice how the hair does not move
**System Information** Operating system: Ubuntu 20.04 Graphics card: GTX 1080 **Blender Version** Broken: d7b231baa87e **Short description of error** When applying a Mesh Sequence Cache (ABC) to a mesh with hair, does not respect the hair correctly. Mesh Cache (PC2) Works correctly. The PC2 reacts the way I would have expected the object to react. Exporting to USD also experiences the same issue as ABC. The file has a few different objects in it, one has the original hair setup. One has an armature (with simple animation). One has this and the hair on it. One has a ABC mesh sequence cache applied to it (which is the issue). and one has a PC2 mesh cache applied to it (works fine) **Aim** We want our animators to animate, without hair on the armature, as this would slow down the file and increase file size. Once animation is ready to light / render / comp, we want to bake out the animation to ABC, apply the mesh cache to the object with hair, and render that. **Exact steps for others to reproduce the error** [bug_v001.blend](https://archive.blender.org/developer/F11565384/bug_v001.blend) [untitled.abc](https://archive.blender.org/developer/F11565404/untitled.abc) [untitled.pc2](https://archive.blender.org/developer/F11565405/untitled.pc2) 1. Download all attached blend files (Blend, ABC and PC2) 2. toggle the viewport visibility of the Mesh Sequence Cache modifier on and off for the ABC Mesh Cache Object. 3. Notice how the hair moves 4. Click on the PC2 Mesh cache object (to the right) 5. Repeat. 6. Notice how the hair does not move

Added subscriber: @candreacchio

Added subscriber: @candreacchio

Files:
bug_v001.blend
untitled.abc
untitled.pc2

These are all relatively mapped, so put them all in the same folder!

Files: [bug_v001.blend](https://archive.blender.org/developer/F11565384/bug_v001.blend) [untitled.abc](https://archive.blender.org/developer/F11565404/untitled.abc) [untitled.pc2](https://archive.blender.org/developer/F11565405/untitled.pc2) These are all relatively mapped, so put them all in the same folder!

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

The mesh cache only deals with mesh data, so the importer doesn't produce curves. ABC & USD try to import hair as curves; however, this is not properly supported by Blender's modifier system. The Alembic importer in Blender 2.79 hacked around this by doing things that were banned in 2.80. To fix this properly, modifiers need to be able to output more than just mesh data. This work is tracked in #51311, and may gain some traction once Blender has a new hair object.

The mesh cache only deals with mesh data, so the importer doesn't produce curves. ABC & USD try to import hair as curves; however, this is not properly supported by Blender's modifier system. The Alembic importer in Blender 2.79 hacked around this by doing things that were banned in 2.80. To fix this properly, modifiers need to be able to output more than just mesh data. This work is tracked in #51311, and may gain some traction once Blender has a new hair object.

Added subscriber: @YegorSmirnov

Added subscriber: @YegorSmirnov

Hm, I don't see the problem?2021-11-01_20-37-40.mp4

Hm, I don't see the problem?[2021-11-01_20-37-40.mp4](https://archive.blender.org/developer/F11662964/2021-11-01_20-37-40.mp4)

In #92561#1245563, @dr.sybren wrote:
The mesh cache only deals with mesh data, so the importer doesn't produce curves. ABC & USD try to import hair as curves; however, this is not properly supported by Blender's modifier system. The Alembic importer in Blender 2.79 hacked around this by doing things that were banned in 2.80. To fix this properly, modifiers need to be able to output more than just mesh data. This work is tracked in #51311, and may gain some traction once Blender has a new hair object.

Hi @dr.sybren ,

I am not trying to bake out the curve data into the ABC file. i am only trying to bake out the mesh data. as in:

  • Animator animate on rig without hair
  • TD Bakes out animation from animator to ABC
  • TD applies the ABC mesh data to the mesh with hair

As in, I am trying ot use ABC, exactly like PC2. No data of hair to be stored in the ABC file.

> In #92561#1245563, @dr.sybren wrote: > The mesh cache only deals with mesh data, so the importer doesn't produce curves. ABC & USD try to import hair as curves; however, this is not properly supported by Blender's modifier system. The Alembic importer in Blender 2.79 hacked around this by doing things that were banned in 2.80. To fix this properly, modifiers need to be able to output more than just mesh data. This work is tracked in #51311, and may gain some traction once Blender has a new hair object. Hi @dr.sybren , I am not trying to bake out the curve data into the ABC file. i am only trying to bake out the mesh data. as in: - Animator animate on rig without hair - TD Bakes out animation from animator to ABC - TD applies the ABC mesh data to the mesh with hair As in, I am trying ot use ABC, exactly like PC2. No data of hair to be stored in the ABC file.

In #92561#1245947, @YegorSmirnov wrote:
Hm, I don't see the problem?2021-11-01_20-37-40.mp4

Hey Yegor.

If you keep it on the frame when the file opens, and toggle the modifier on and off, you should see that the hair shifts around.

This is a test file, however on our production file, the hair on our creature is going beneath its skin, giving a 'patchy' look and not respecting how we have groomed it.

> In #92561#1245947, @YegorSmirnov wrote: > Hm, I don't see the problem?[2021-11-01_20-37-40.mp4](https://archive.blender.org/developer/F11662964/2021-11-01_20-37-40.mp4) Hey Yegor. If you keep it on the frame when the file opens, and toggle the modifier on and off, you should see that the hair shifts around. This is a test file, however on our production file, the hair on our creature is going beneath its skin, giving a 'patchy' look and not respecting how we have groomed it.
Member

Added subscribers: @brecht, @lichtwerk

Added subscribers: @brecht, @lichtwerk
Member

I can confirm as well.

@dr.sybren : this is about the hair system (interpolated children distribution) behaving awkward on a ABC driven mesh (not about real curves in ABC).

Couple of notes:

  • This only happens with interpolated children
  • Reminds me of #56408 (Hair interpolated children recalculation on every frame when attached onto an alembic imported mesh) (issues with distribution code explained)
  • I think the distribution is not even the same on Original Hair Setup & Armature with Hair in restpose (they should, but if you look closely I think they arent)
  • True, even though mesh with ABC applied seems to be exactly the same as the orig mesh in terms of coordinates (think it also should since ee8aad79c1), dristribution is not the same

Maybe @brecht can let us know if the distribution code of interpolated children is just in the status of a Known Issue?

That being said, there is one possible way to get consistent output throughout the pipeline (at least as far as I can tell) -- so Original Hair Setup, Armature with Hair & ABC Mesh Cache With Hair could all look the same:

  • Use a Triangulate modifier before the particle system in each step of the pipeline
  • Enable Use modifier stack on the particle system
  • (You'd probably have to adjust grooms on existing Hair Setups [slightly] to compensate unfortunately)

bug_v001_triangulate_use_modifier_stack.blend

The usage of the triangulate modifier also reminds me of #91777 (Mesh is not being deformated correctly via Mesh Deform Modifier (quads, tris behave better)) (which is nice to know in itself)

I can confirm as well. @dr.sybren : this is about the hair system (interpolated children distribution) behaving awkward on a ABC driven mesh (not about real curves in ABC). Couple of notes: - This only happens with interpolated children - Reminds me of #56408 (Hair interpolated children recalculation on every frame when attached onto an alembic imported mesh) (issues with distribution code explained) - I think the distribution is not even the same on `Original Hair Setup` & `Armature with Hair` in restpose (they should, but if you look closely I think they arent) - True, even though mesh with ABC applied seems to be exactly the same as the orig mesh in terms of coordinates (think it also should since ee8aad79c1), dristribution is not the same Maybe @brecht can let us know if the distribution code of interpolated children is just in the status of a `Known Issue`? That being said, there is one possible way to get consistent output throughout the pipeline (at least as far as I can tell) -- so `Original Hair Setup`, `Armature with Hair` & `ABC Mesh Cache With Hair` could all look the same: - Use a `Triangulate` modifier before the particle system in each step of the pipeline - Enable `Use modifier stack` on the particle system - (You'd probably have to adjust grooms on existing Hair Setups [slightly] to compensate unfortunately) [bug_v001_triangulate_use_modifier_stack.blend](https://archive.blender.org/developer/F11727422/bug_v001_triangulate_use_modifier_stack.blend) The usage of the triangulate modifier also reminds me of #91777 (Mesh is not being deformated correctly via Mesh Deform Modifier (quads, tris behave better)) (which is nice to know in itself)
Philipp Oeser changed title from Blender 3.0 - Mesh Sequence Cache (ABC) does not work correctly with hair to Mesh Sequence Cache (ABC) an hair interpolated children distribution issue (triangulate modifier seem to fix it) 2021-11-05 10:12:39 +01:00
Member

Note this will probably all change for the better with #68981 (New curves object type)

Note this will probably all change for the better with #68981 (New curves object type)

I don't think this is a known issue. As far as I know as long as the mesh topology coming from the Alembic file is stable, and the fix from ee8aad79c1 to keep stable original coordinates is giving stable ORCO, then the child particle distribution should remain stable too,

Why it's failing in this file is not immediately clear to me, needs some deeper investigation.

I don't think this is a known issue. As far as I know as long as the mesh topology coming from the Alembic file is stable, and the fix from ee8aad79c1 to keep stable original coordinates is giving stable ORCO, then the child particle distribution should remain stable too, Why it's failing in this file is not immediately clear to me, needs some deeper investigation.

Just to clarify, this has happened in a more prominent way on a production scene. The scene provided is myself recreating the issue to give an example of what is going wrong, and not the worst case of it.

Just to clarify, this has happened in a more prominent way on a production scene. The scene provided is myself recreating the issue to give an example of what is going wrong, and not the worst case of it.

Is this something that was recently introduced? Did it ever work well for you @candreacchio in older versions of Blender?

Is this something that was recently introduced? Did it ever work well for you @candreacchio in older versions of Blender?

i can test this weekend if it would be useful. but no this is the first time we are trying it with hair.

i can test this weekend if it would be useful. but no this is the first time we are trying it with hair.
Member

2.80 introduced the jump on enabling the modifier, in 2.79, you can enable/disable without the jump:
bug_v001_279.blend
(but then again in 2.79 the distribution never really looks the same, so Original Hair Setup, Armature with Hair & ABC Mesh Cache With Hair all look [slightly] different -- and in 2.79, the triangulate modifier workaround does not seem to help)

2.80 introduced the jump on enabling the modifier, in 2.79, you can enable/disable without the jump: [bug_v001_279.blend](https://archive.blender.org/developer/F11793443/bug_v001_279.blend) (but then again in 2.79 the distribution never really looks the same, so `Original Hair Setup`, `Armature with Hair` & `ABC Mesh Cache With Hair` all look [slightly] different -- and in 2.79, the triangulate modifier workaround does not seem to help)

Added subscriber: @kevindietrich

Added subscriber: @kevindietrich

After some investigation the problem appears to be that the ORCOs as expected by the particle system have to be in the 0...1 range, at least this is what the particle system is using to create & store ORCOs when none exist on the Mesh (see https://developer.blender.org/diffusion/B/browse/master/source/blender/blenkernel/intern/particle_distribute.c$1000). However, the ORCOs as read from Alembic or as generated via MOD_deform_mesh_eval_get are not normalized.

This little patch fixes the issue:

diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index d57e92b4b35..514ffde3683 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -219,8 +219,9 @@ Mesh *MOD_deform_mesh_eval_get(Object *ob,
     }
 
     if (use_orco) {
-      CustomData_add_layer(
-          &mesh->vdata, CD_ORCO, CD_ASSIGN, BKE_mesh_orco_verts_get(ob), mesh->totvert);
+      float(*orcodata)[3] = BKE_mesh_orco_verts_get(ob);
+      BKE_mesh_orco_verts_transform(mesh, orcodata, mesh->totvert, false);
+      CustomData_add_layer(&mesh->vdata, CD_ORCO, CD_ASSIGN, orcodata, mesh->totvert);
     }
   }
   else if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {

So, if all ORCOs should be stored in 0...1 range, then I can make a patch to ensure that all areas (like Alembic, USD, etc.) are also outputting normalized ORCOs.

But also, it seems like the code in MOD_deform_mesh_eval_get is ignoring a potential CD_ORCO layer on the mesh? At least one should be read from the Alembic file but it is never used.

After some investigation the problem appears to be that the ORCOs as expected by the particle system have to be in the 0...1 range, at least this is what the particle system is using to create & store ORCOs when none exist on the Mesh (see https://developer.blender.org/diffusion/B/browse/master/source/blender/blenkernel/intern/particle_distribute.c$1000). However, the ORCOs as read from Alembic or as generated via `MOD_deform_mesh_eval_get` are not normalized. This little patch fixes the issue: ``` diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index d57e92b4b35..514ffde3683 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -219,8 +219,9 @@ Mesh *MOD_deform_mesh_eval_get(Object *ob, } if (use_orco) { - CustomData_add_layer( - &mesh->vdata, CD_ORCO, CD_ASSIGN, BKE_mesh_orco_verts_get(ob), mesh->totvert); + float(*orcodata)[3] = BKE_mesh_orco_verts_get(ob); + BKE_mesh_orco_verts_transform(mesh, orcodata, mesh->totvert, false); + CustomData_add_layer(&mesh->vdata, CD_ORCO, CD_ASSIGN, orcodata, mesh->totvert); } } else if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { ``` So, if all ORCOs should be stored in 0...1 range, then I can make a patch to ensure that all areas (like Alembic, USD, etc.) are also outputting normalized ORCOs. But also, it seems like the code in `MOD_deform_mesh_eval_get` is ignoring a potential CD_ORCO layer on the mesh? At least one should be read from the Alembic file but it is never used.

Added subscriber: @Memento

Added subscriber: @Memento

Removed subscriber: @Memento

Removed subscriber: @Memento

Maybe @brecht knows more about how ORCOs should be stored? Also I find it strange that, if ORCOs should always be stored normalized, that they aren't normal when they're read from Alembic -- after all, they should have already been normal when they were written.

Maybe @brecht knows more about how ORCOs should be stored? Also I find it strange that, if ORCOs should always be stored normalized, that they aren't normal when they're read from Alembic -- after all, they should have already been normal when they were written.

They are currently stored normalized. I'd actually like to change that to not be the case, but it's not a trivial change.

In other applications this is often called Pref (P for position, and ref for reference like a a reference pose in rigging). So for interop, I think it would be best to read/write orcos as an unnormalized Pref attribute in Alembic and USD. That could be done without changing how it's stored internally.

They are currently stored normalized. I'd actually like to change that to not be the case, but it's not a trivial change. In other applications this is often called `Pref` (`P` for position, and `ref` for reference like a a reference pose in rigging). So for interop, I think it would be best to read/write orcos as an unnormalized `Pref` attribute in Alembic and USD. That could be done without changing how it's stored internally.

This issue was referenced by 77694b571f

This issue was referenced by 77694b571f5bd297ea7228b30f591ebbd333e0ea

This issue was referenced by 02ab4ad991

This issue was referenced by 02ab4ad991906f817698d3810c3d464cfaedcaff

Will this be committed for the next blender release?

Will this be committed for the next blender release?

Added subscriber: @Memento

Added subscriber: @Memento

Removed subscriber: @Memento

Removed subscriber: @Memento

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Kévin Dietrich self-assigned this 2021-12-01 12:45:28 +01: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
9 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#92561
No description provided.