Hair Dynamics: cannot generate a valid particle cache #62563

Open
opened 2019-03-14 02:28:33 +01:00 by Garry R. Osgood · 13 comments

System Information
Operating system: 4.20.12-gentoo Linux
Graphics card: Radeon(TM) Pro WX9100 (VEGA10, DRM 3.27.0, 4.20.12-gentoo, LLVM 6.0.1)

Blender Version
Broken: 2.80 (sub 48) commit hash: bf9904ec80 Build: 2019-03-13 01:14:16 Linux Release branch: blender2.7

Worked: (optional) 2.79b commit hash and date unknown; compiled from Gentoo repository

Short description of error
Fails to make a valid particle cache when rendering a dynamic hair system via Cntl + F12. Hair particle motion appears compromised after the first frame. see video clip dyn_on.mkv.

Require
A .blend file with a mesh object that has a hair particle system defined on it. Hair dynamics is turned on in the particle system properties panel. The file should have been previously saved without a cache. Blend file dyn_on.blend provided for this requirement.

Exact steps for others to reproduce the error

  1. Open dyn_on.blend
  2. Cntl + F12 to render animation (implicitly build in-memory cache)
  3. Observe:
 a. Cache indicator on timeline shows only 1 or 2 valid initial frames; remaining 248 - 249 frames are invalid.
 b. Hair particles exhibit only limited rotational dynamics. They do not follow the surface of the sphere (i.e., they appear "unanchored"), nor do they seem affected by gravity. See **dyn_on.mkv** video clip.
 c. After the last frame has been rendered, click on the rewind control in the timeline. The cache section in the Particles properties reports the state of the cache: "1 frames in memory (216 KB), not exact since frame 0"

Workaround

  1. Bake particle dynamics first or
  2. Run the animation through in the 3D viewport to create an in-memory or on disk cache before rendering.

Rendering with an in-memory, on-disk, or with baked dynamics appears to generate an unaffected animation. See dyn_on_cache.mkv video clip.

Notes:

  1. Examples rendered in Cycles, but EEVEE and Workbench rendering does not change behavior.
  2. Hair particles rendered with a collection of simple mesh geometry in the examples, but rendering with single mesh objects or rendering hair paths does not change behavior.
  3. Running in single thread mode (-t 1 on command line) does not change behavior.
  4. Rendering via CPU or GPU does not change behavior.
  5. Problem seems specific to hair particle systems. Emitter particle systems without pre-computed caches can be rendered with Cntl + F12; the cache seems fully valid in the time line, dynamics of falling emitter particles do not seem unusual and the cache section in the Particles properties reports that there are 250 valid frames in memory at the conclusion of the animation.

Related:
#62439 describes a failure in particle updates which seems very similar in appearance exhibited by particles in video clip dyn_on.mkv.

dyn_on_cache.mkv - dyn_on_cache.mkv
dyn_on.mkv - dyn_on.mkv
dyn_on.blend - dyn_on.blend

**System Information** Operating system: 4.20.12-gentoo Linux Graphics card: Radeon(TM) Pro WX9100 (VEGA10, DRM 3.27.0, 4.20.12-gentoo, LLVM 6.0.1) **Blender Version** Broken: 2.80 (sub 48) commit hash: bf9904ec8018 Build: 2019-03-13 01:14:16 Linux Release branch: blender2.7 Worked: (optional) 2.79b commit hash and date unknown; compiled from Gentoo repository **Short description of error** Fails to make a valid particle cache when rendering a dynamic hair system via Cntl + F12. Hair particle motion appears compromised after the first frame. see video clip **dyn_on.mkv**. **Require** A .blend file with a mesh object that has a hair particle system defined on it. Hair dynamics is turned on in the particle system properties panel. The file should have been previously saved without a cache. Blend file **dyn_on.blend** provided for this requirement. **Exact steps for others to reproduce the error** 1. Open **dyn_on.blend** 2. Cntl + F12 to render animation (implicitly build in-memory cache) 3. Observe: ``` a. Cache indicator on timeline shows only 1 or 2 valid initial frames; remaining 248 - 249 frames are invalid. b. Hair particles exhibit only limited rotational dynamics. They do not follow the surface of the sphere (i.e., they appear "unanchored"), nor do they seem affected by gravity. See **dyn_on.mkv** video clip. c. After the last frame has been rendered, click on the rewind control in the timeline. The cache section in the Particles properties reports the state of the cache: "1 frames in memory (216 KB), not exact since frame 0" ``` **Workaround** 1. Bake particle dynamics first or 2. Run the animation through in the 3D viewport to create an in-memory or on disk cache before rendering. Rendering with an in-memory, on-disk, or with baked dynamics appears to generate an unaffected animation. See **dyn_on_cache.mkv** video clip. **Notes:** 1. Examples rendered in Cycles, but EEVEE and Workbench rendering does not change behavior. 2. Hair particles rendered with a collection of simple mesh geometry in the examples, but rendering with single mesh objects or rendering hair paths does not change behavior. 3. Running in single thread mode (-t 1 on command line) does not change behavior. 4. Rendering via CPU or GPU does not change behavior. 5. Problem seems specific to hair particle systems. Emitter particle systems without pre-computed caches can be rendered with Cntl + F12; the cache seems fully valid in the time line, dynamics of falling emitter particles do not seem unusual and the cache section in the Particles properties reports that there are 250 valid frames in memory at the conclusion of the animation. **Related:** #62439 describes a failure in particle updates which seems very similar in appearance exhibited by particles in video clip **dyn_on.mkv.** [dyn_on_cache.mkv](https://archive.blender.org/developer/F6818202/dyn_on_cache.mkv) - dyn_on_cache.mkv [dyn_on.mkv](https://archive.blender.org/developer/F6818196/dyn_on.mkv) - dyn_on.mkv [dyn_on.blend](https://archive.blender.org/developer/F6818180/dyn_on.blend) - dyn_on.blend

Added subscriber: @grosgood

Added subscriber: @grosgood

#71996 was marked as duplicate of this issue

#71996 was marked as duplicate of this issue

Added subscribers: @dfelinto, @ZedDB

Added subscribers: @dfelinto, @ZedDB
Dalai Felinto was assigned by Sebastian Parborg 2019-03-14 12:53:37 +01:00

I could have sworn there was already a ticket for this (particles not simulating when rendering without a cache), but I can't find it if that is the case.

@dfelinto reassign if this is not for you.

I could have sworn there was already a ticket for this (particles not simulating when rendering without a cache), but I can't find it if that is the case. @dfelinto reassign if this is not for you.

In blenkernel/intern/particle.c:psys_cache_paths, a N X (S + 1) array of "hair segment vertices" is built for the N hairs in the particle system, each with S segments. So for four segment hairs, there is a root, tip, and three interior hair vertices, for a total of 5. These "hair vertices" are distinct from model geometry vertices.

This pathcache "bucket" is created fresh at the start of rendering each frame and populates the particle system's pathcache field. psys_cache_paths() appears to develop a "snapshot" of positions, velocities and rotations of each hair vertex at the present frame.

It is not clear to me why this is so, but it seems in the case of Cntl + F12, without prior baking or creating an in-memory/disk cache, that the position, rotation or velocity of the underlying mesh appears not to be incorporated in the calculation of hair vertex positions, rotations or velocities. Watching the content of the pathcache in GDB during a rendering reveals unchanging positions frame after frame. This is not the case in baked/prior pointcache circumstances;
the pathcache appears to reflect the dynamics of the underlying object mesh.

One is tempted to think of an omitted transform somewhere, but I suspect that the problem is more diffuse than a dropped matrix. Fortunately, the severity of this bug is somewhere between a paper cut and a mild annoyance, since the workaround is simply to generate a point cache or bake the dynamics, and do such workarounds until the Glorious Rewrite of Particle Systems takes place. On the other hand, one would like to think that a shiny, production-ready 2.80 is going to be feature complete in every respect. One hates to let go of ideals.

In blenkernel/intern/particle.c:psys_cache_paths, a N X (S + 1) array of "hair segment vertices" is built for the N hairs in the particle system, each with S segments. So for four segment hairs, there is a root, tip, and three interior hair vertices, for a total of 5. These "hair vertices" are distinct from model geometry vertices. This pathcache "bucket" is created fresh at the start of rendering each frame and populates the particle system's pathcache field. psys_cache_paths() appears to develop a "snapshot" of positions, velocities and rotations of each hair vertex at the present frame. It is not clear to me why this is so, but it seems in the case of Cntl + F12, without prior baking or creating an in-memory/disk cache, that the position, rotation or velocity of the underlying mesh appears not to be incorporated in the calculation of hair vertex positions, rotations or velocities. Watching the content of the pathcache in GDB during a rendering reveals unchanging positions frame after frame. This is not the case in baked/prior pointcache circumstances; the pathcache appears to reflect the dynamics of the underlying object mesh. One is tempted to think of an omitted transform somewhere, but I suspect that the problem is more diffuse than a dropped matrix. Fortunately, the severity of this bug is somewhere between a paper cut and a mild annoyance, since the workaround is simply to generate a point cache or bake the dynamics, and do such workarounds until the Glorious Rewrite of Particle Systems takes place. On the other hand, one would like to think that a shiny, production-ready 2.80 is going to be feature complete in *every* respect. One hates to let go of ideals.

Added subscribers: @Sergey, @dr.sybren

Added subscribers: @Sergey, @dr.sybren

@ZedDB let's find someone else that actually is familiar with this area ;) @Sergey worked on hair, @dr.sybren worked on cache, ...

@ZedDB let's find someone else that actually is familiar with this area ;) @Sergey worked on hair, @dr.sybren worked on cache, ...

Notes based on blender 2.80 commit: 7454fa927b Sat Mar 23 14:25:29 2019 +1100 #62563 still persists in this blender version.

Close to the heart of the matter is a - perhaps incomplete - meshing of designs of how dependency graph (depsgraph) updates proceed in the
rendering context and view layer context.

Frame-to-frame dependency graphs updates occur in two contexts: rendering, the consequence of CNTL F12, and view layer updates, the
consequence of running the timeline pointer forward.

These two contexts do not manage dependency graph updates in exactly the same way. In the rendering context, a per-frame call to
BKE_object_free(Object *ob), object.c:553, takes place, which frees the particle systems in ListBase ob->particlesystem. It is an array of
PointCaches deeper in these structures which encapsulate the state of frame T for hair simulators, which compute from them frame T + 1.
These PointCaches are freed as well and are not reconstructed in the course of the dependency graph update for frame T + 1. This
circumstance gives rise to the main feature of this bug: a hair simulation that essentially restarts from an initial T = 1 state
on every frame.

In contrast, the view layer context does not employ the draconian data management policy of BKE_object_free() at all. Only by toggling on the
Hair Dynamics checkbox property in the Particle panel does one see BKE_object_free(Object *ob) called on mesh objects with particle
systems. It is not called per-frame when one scrubs the timeline forward. Consequently, PointCache state persists from frame-to-frame and
hair simulation proceeds in an expected fashion.

Details in partsystem_notes.txt, attached.partsystem_notes.txt

Notes based on blender 2.80 commit: 7454fa927b80 Sat Mar 23 14:25:29 2019 +1100 #62563 still persists in this blender version. Close to the heart of the matter is a - perhaps incomplete - meshing of designs of how dependency graph (depsgraph) updates proceed in the rendering context and view layer context. Frame-to-frame dependency graphs updates occur in two contexts: rendering, the consequence of CNTL F12, and view layer updates, the consequence of running the timeline pointer forward. These two contexts do not manage dependency graph updates in exactly the same way. In the rendering context, a per-frame call to BKE_object_free(Object *ob), object.c:553, takes place, which frees the particle systems in ListBase ob->particlesystem. It is an array of PointCaches deeper in these structures which encapsulate the state of frame T for hair simulators, which compute from them frame T + 1. These PointCaches are freed as well and are not reconstructed in the course of the dependency graph update for frame T + 1. This circumstance gives rise to the main feature of this bug: a hair simulation that essentially restarts from an initial T = 1 state on every frame. In contrast, the view layer context does not employ the draconian data management policy of BKE_object_free() at all. Only by toggling on the Hair Dynamics checkbox property in the Particle panel does one see BKE_object_free(Object *ob) called on mesh objects with particle systems. It is not called per-frame when one scrubs the timeline forward. Consequently, PointCache state persists from frame-to-frame and hair simulation proceeds in an expected fashion. Details in partsystem_notes.txt, attached.[partsystem_notes.txt](https://archive.blender.org/developer/F6876637/partsystem_notes.txt)

[Commit ]]: 5494683651 (November 9, 2018) appears to have set the stage for this bug, which is a side effect. Very close to the heart of the matter is the hair dynamics simulation depending on the persistence of the same ParticleSystem object across the initial three frames of animation. With the commit, the prerequisite continuity of ParticleSystems can no longer be guaranteed, as they are reinitialized with the frame-by-frame deletion and recreation of the rendering dependency graph. Currently I'm wandering through the rabbit hutch that is [ https:*developer.blender.org/diffusion/B/browse/master/source/blender/blenkernel/intern/particle_system.c | particle_system_update() and friends, looking for either Big Buck Bunny, a contemporary of the code, it seems, or a way for ParticleSystems to be stateless - or at least less stateful. Simpler flavors of simulations, such as hair without dynamics or particle emitters, do not have equivalent dependencies on persisting ParticleSystem objects, and were unaffected by the November commit.

Details in partsystem_notes_2.txt, attached.
partsystem_notes_2.txt

[Commit ]]: 549468365157 (November 9, 2018) appears to have set the stage for this bug, which is a side effect. Very close to the heart of the matter is the hair dynamics simulation depending on the persistence of the same ParticleSystem object across the initial three frames of animation. With the commit, the prerequisite continuity of ParticleSystems can no longer be guaranteed, as they are reinitialized with the frame-by-frame deletion and recreation of the rendering dependency graph. Currently I'm wandering through the rabbit hutch that is [[ https:*developer.blender.org/diffusion/B/browse/master/source/blender/blenkernel/intern/particle_system.c | particle_system_update() ](https:*developer.blender.org/rB549468365157a075949f2d4b8d9496ff719cefbf) and friends, looking for either Big Buck Bunny, a contemporary of the code, it seems, or a way for ParticleSystems to be stateless - or at least less stateful. Simpler flavors of simulations, such as hair without dynamics or particle emitters, do not have equivalent dependencies on persisting ParticleSystem objects, and were unaffected by the November commit. Details in partsystem_notes_2.txt, attached. [partsystem_notes_2.txt](https://archive.blender.org/developer/F6908892/partsystem_notes_2.txt)
Philipp Oeser changed title from Cannot generate a valid particle cache for dynamic hair particles to Hair Dynamics: cannot generate a valid particle cache 2019-09-04 20:22:30 +02:00
Dalai Felinto was unassigned by Philipp Oeser 2019-09-04 20:22:30 +02:00
Member

Added subscribers: @PaulHartsuyker, @lichtwerk

Added subscribers: @PaulHartsuyker, @lichtwerk
Member

#71996 (Hair doesn't work, simple turnaround animation.) has a file that I cannot bake at all [there is never more that one valid frame in the cache.... no time to investigate more, just saying...]

#71996 (Hair doesn't work, simple turnaround animation.) has a file that I cannot bake at all [there is never more that one valid frame in the cache.... no time to investigate more, just saying...]

Per [Tracker Curfew ]], [ https:*lists.blender.org/pipermail/bf-committers/2019-December/050383.html|Tracker curfew and developer.blender.org changes and #71418
Known issue: user documentation could use a Note box to the effect that caches cannot be generated for dynamic hair by means of a final render ( Cntl + F12 ), but generating a cache for dynamic hair by previewing the animation in the view port or baking hair dynamics works. In these two cases the particle system interacts with a persistent depsgraph in Viewport mode. Render depsgraphs do not persist but are recreated frame-by-frame. The hair particle system has not been designed to interact with transient depsgraphs.

Per [Tracker Curfew ]], [[ https:*lists.blender.org/pipermail/bf-committers/2019-December/050383.html|Tracker curfew and developer.blender.org changes ](https:*code.blender.org/2019/12/tracker-curfew/) and #71418 Known issue: user documentation could use a Note box to the effect that caches cannot be generated for dynamic hair by means of a final render ( Cntl + F12 ), but generating a cache for dynamic hair by previewing the animation in the view port or baking hair dynamics works. In these two cases the particle system interacts with a persistent depsgraph in Viewport mode. Render depsgraphs do not persist but are recreated frame-by-frame. The hair particle system has not been designed to interact with transient depsgraphs.

Removed Tracker Curfew tag per discussion between @dr.sybren and @dfelinto: Re: Tracker curfew and developer.blender.org changes Identified as a known issue.

Removed Tracker Curfew tag per discussion between @dr.sybren and @dfelinto: [Re: Tracker curfew and developer.blender.org changes ](https://lists.blender.org/pipermail/bf-committers/2019-December/050386.html) Identified as a known issue.
Philipp Oeser removed the
Interest
Nodes & Physics
label 2023-02-10 08:47:58 +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
5 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#62563
No description provided.