Point Cache replacement based on Alembic #37578
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
FBX
Interest
Freestyle
Interest
Geometry Nodes
Interest
glTF
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 & 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
Viewport & EEVEE
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
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
45 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#37578
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The goal of this project is to implement a new Point Cache system based on the Alembic library and unify the various caching methods used in Blender.
This is a prerequisite for further work on particle systems. Having a working Alembic exporter/importer will also greatly benefit integration of Blender into larger pipelines.
Current Issues
Proposal
Keep basic cache settings on Scene level:
Optional overrides on object/sim level
Question: How do we handle automatic caching?
Question: Do we really need multiple caches for each object? This feature adds a list of point caches for every object, only the active cache is used, the others are basically a version control system. Could this be moved to the scene level? The problem with this way of "versioning" is that there is really no way to roll back to a previous version, other than comparing the results without any way to revert settings.
Directory and File Names
How should directories and file naming work?
Current naming scheme works per object and uses a combination of output directory + filename:
//blendcache_<blend file name>/
(if .blend is saved and thus relative paths work)or using a temp folder like
<tmp folder>/blendcache/
<basename>_<frame number>_<cache index>.bphys
<basename>
can be specified by the user or otherwise the ID datablock name (usually Object) is used<cache index>
is generated automatically by default (-1), but needed if multiple caches exist in the same ID block.Frames, Times and Sample Indices
There are 3 different modes of interpreting "time" that need to be managed in a clean way:
While it would be possible to largely ignore time sampling for Blender cache files and simply read each cached sample as a frame, it is probably more reliable and flexible to calculate time values as defined by the scene render range and fps settings. This would allow using externally generated Alembic files which use a different sampling rate than the current scene and map them into the scenes frame range.
Ultimately it could be very useful to integrate cached data into the NLA editor as a track. At that point the direct sample<->frame relationship that might still exist for cached data from the same scene is useless anyway.
Proposed Changes
Modifiers
Almost all cacheable data is located somewhere in modifier stacks, so these require some special attention. While caching the final result of mesh modifier evaluation (
final_dm
) is obviously useful, we also want to support partial caching and layered evaluation of mesh stages and simulation.Proposal
final_dm
result. Caching can be disabled entirely by disabling this modifier. [Is it preferable to leave this completely to the user and not do any modifier caching at all by default?]Open Questions
Caching vs. Export
These two cases may need to have somewhat different requirements in terms of necessary data attributes, sampling, etc. (while running the same backend input/output functions).
Implementation
(somewhat outdated)
Notes
Changed status to: 'Open'
Added subscriber: @plasmasolutions
Added subscriber: @jasperge-2
Added subscriber: @MartinLindelof
Added subscriber: @JayrajKharvadi
In my development branch i have now removed the point cache ListBases. As noted in the task description this feature does not add much value and it made the code unnecessarily complicated.
Older cache data is only useful for comparing to newer results, but one cannot actually revert to the previous settings just from the cache - for this you need to actually save a different .blend file version, which has its own cache anyway ... Such versioning functionality needs to be handled as part of the asset management or simply by making cache data backups outside of Blender.
The RNA code for accessing the point_caches collection was also causing recursion issues, basically the point cache contained a reference to itself, which is bad. Without the need to handle potential lists everywhere the code as well as the workflow becomes much simpler.
Added subscriber: @lichtwerk
Added subscriber: @JonathanWilliamson
Added subscriber: @Brachi
Added subscriber: @mont29
Added subscriber: @krupa-2
Added subscriber: @SayantanChaudhuri
Removed subscriber: @SayantanChaudhuri
Added subscriber: @italic
I'd like point caches to works as unobtrusively as possible. However, in order to store a valid state of the simulation/modifier results and keep in sync with the user settings some rules need to be established.
The current scheme works like this:
I'd like to know if and how this system could be improved.
For a start, it's not really necessary to perform a full simulation over the whole frame range if the cache is already valid. Then we could have an option "lock/unlock" instead of the "bake"/"free bake" operators. What this means is that, when locked, a simulation/modifier will never perform calculations but try to read results from the cache. If no valid cache result is available for a frame this should be clearly indicated in both the property buttons and the 3D viewport (instead of misplaced particles/etc. like it often happens now).
Notice how "lock" refers to the simulation settings rather than the cache! It can be seen as a 3rd option in addition to completely enabling/disabling a simulation - expensive calculations are avoided and the simulation is treated as read-only data.
In addition to, and separate from this, there can be a "bake"/"full update" operator. What this does is simply run through the simulation frame range once to calculate correct results for every frame and cache them. This can be a scene-wide operator, since generally a simulation is calculated in relation to other objects, so there is no need to re-run this for every simulation on its own. Essentially this is a slightly modified "run animation" (alt+a) operator, which just runs through the frame range once instead of looping.
After performing this "full update" there will be valid results for every frame, so it makes sense to lock the simulation settings. But it's not necessary and could be left to the user. A clear indicator for "all frames cached" should help.
Added subscriber: @zanqdo
Hi Lukas, I'm thinking this more from the character animation workflow than the simulation workflow. I think there can be 2 types of point cache: the manual persistent cache and the automatic disposable cache. This could create a solid difference between actual simulation cache and just playback stuff like frame-scrubbing a sim that can be easily recreated.
The disposable cache could be set to automatically cache even general animation data (from modifier stack) so that for example consecutive playbacks with a few heavy characters are greatly accelerated, only recalculating the needed parts or characters and completely skipping calculation of the rest.
The persistent cache is more like when you decide to bake and lock a character so that it becomes uneditable unless you decide to release the persistent cache, make some edits and maybe bake again.
The persistent cache can have the added ability of remapping the timing and other nice tricks.
Edit: I just read your last comment @LukasTonne, you're already planning some kind of locking behavior. Great, just hoping we can extend this concept to anything worth caching and not only to simulations.
Added subscriber: @AditiaA.Pratama
Added subscriber: @BassamKurdali
Thinking from a project pipeline perspective: It would be invaluable at render time to render only caches, not rigged characters. Several advantages accrue:
No issue with renderfarms with linking, Python scripts, drivers, etc that might require 'unsafe' setting to render correctly
Secondary thing that would be really cool is sculpting on caches, keying caches etc.
I'm curious how this would play into final rendering, such as motion blur and sub-frame animation. I know it's possible to export a cache in sub-frame increments, but how motion blur will work is beyond me. Does Alembic have any provisions for this or will it be entirely up to Blender (or other software of preference) to interpret and interpolate between cache steps?
@zanqdo: Yes, a form of locking could certainly be helpful to prevent accidentally losing cached data, combined with operators that calculate the whole cache to ensure it is valid in every frame. I just think that we need to keep the cache away from the simulations for the sake of design.
@BassamKurdali: I think this goes in the same direction as the last point above: Keep rig/mod/sim settings (collectively "cache writers") separate from instances ("cache readers"), which can add further modifications on top of the cached data (lighting, timing, materials, ...). I'll try to make a coherent design proposal for this.
Sculpting on cached data is a cool idea, which is only partially realized in "particle edit mode" so far. There are some tricky challenges though, like how to visualize the time domain in a meaningful way. When you compare it to regular sculpting: there you have a brush with some spatial extent whose effect can be shown all at once (all mesh vertices visible at the same time). But if you modify cache data at one point in time it's not so easy to show how this changes in the time dimension. "Ghost frames" are one approach, but it's most suitable for point data (like particles), i think it becomes difficult for use with surface geometry. Maybe there are proven solutions ...
@italic: Alembic does not do interpolation itself, but it is quite flexible in how it stores sub-frame samples. An Alembic file can have multiple different "time samplings", which usually relates to the frames. The standard would be 1-sample-per-frame, but we can add more fine-grained sampling next to it for fast moving objects that require detailed motion blur.
How this data is then interpreted for rendering etc. is up to Blender. IIRC our current renderers use spline segments to model the subframe motion of objects, which is good enough in most cases.
Added subscriber: @BeornLeonard
Removed subscriber: @MartinLindelof
Added subscriber: @sarazinjean-francois
Hello Lukas! When you ask :Do we really need multiple caches for each object? There is an important parameter, when we work with teamates, animators often overwrite pointcache for only a character, and render team sees updates in its scene. Would it be possible to do this if there is only one big cache file for the scene? Would it possible to link a character from a file, and a set from another file? And would it be possible to overwrite a file while someone else is reading it?
@sarazinjean-francois: The "multiple caches for each object" refers to the list feature in every single object. This has very limited use and causes a number of complications in the code.
That being said, i like the concept of instancing cached data. I have outlined this a bit above, but needs to get a more precise design. Basically the current caches are very closely attached to the objects that generate them, making an object that works only as a cache instance is really cumbersome atm (requires using "external" caches and mismatching settings can easily break it).
Reading/writing cache files simultaneously should be as smooth as possible. I have to investigate the details of how Alembic files can be accessed more-or-less simultaneously, but generally it should follow a one writer / multiple readers model. Using the cached result of a writer in the same frame would be nice, the depgraph should enable us to let the writer finish writing the result in that frame before readers access it for instancing.
This writer reader thing seems great.
Instancing cache could be like image management. It sounds good to me. By the way, i think cache should be written with absolute frames, and not in seconds. Time management should be the software Task . I rather keep things simple, ie for compositing it is easier to work with images sequences, as soon you work with movie file you have some framerate issue between projects.
Added subscriber: @ErickNyanduKabongo
@sarazinjean-francois: The "time" values in Alembic are not per-se seconds. We can also interpret the time values as frames (1 frame = time interval of 1.0) instead of scaling by the fps (1 frame = time interval of 1/fps). This can be changed fairly easily though, so we can have a look at what would work best for interchangeability (the ominous "industry standard").
Added subscriber: @sreich
Added subscriber: @WarrenBahler
I just discovered the point animation features in messiah studio.
would the task here bring blender closer to implementing functionality like this?:
http://www.usefulslug.com/messiah4/PointAnimationSmall.mov
this would make animation extremely powerful, especially for lip syc, muscle animation, small cloth effects and so on....
@WarrenBahler Just so you know you can do this with the AnimAll addon
@zanqdo Wow, I didn't realize you can actually edit the mesh with Animall, very cool work, thanks
Added subscriber: @z0r
Added subscriber: @BartekMoniewski
Added subscriber: @nmitchell
@WarrenBahler @zanqdo actually it's a good question: is there anything in the design above that would prevent sculpting directly on the cache (not on the underlying mesh) ? the diagrams don't show this but don't explicitly prevent it either.
Added subscriber: @kevindietrich
Added subscriber: @k9crunch
Added subscriber: @mrt3d
Added subscriber: @FlorianRichter
Added subscriber: @obadonke
Added subscriber: @andreas.atteneder
Added subscriber: @pyrochlore
Added subscriber: @RobertIves
Added subscriber: @boby
Added subscriber: @MaxHammond
Added subscriber: @karja
Added subscriber: @g-lul
Added subscriber: @ideasman42
Generally agree scene level baking is good so not much comments on what is written in the proposal.
Some feedback:
re:
simulations independent from the animation playback by default
- This seems fine to me. If you want real result you need to play from start or bake it.re:
Do we really need multiple caches for each object?
- I think not, but its worth considering how/if we might use multiple alembic files per scene.Other comments: ... questions infact!
Added subscriber: @MobyMotion
Added subscriber: @MikePan
Added subscriber: @Wei-ChengSun
Added subscriber: @xuekepei
Added subscriber: @ManuelGrad
Added subscriber: @dr.sybren
Alembic explicitly does not allow changing an existing file, and from my experience does not even allow opening a file for reading unless it has been properly closed for writing (my hunch is that it writes some index only on closing). There are no provisions for simultaneous access, and writing to a file that's opened for reading will actually cause an exception (#51141). As a result, I have serious doubts about the usability of Alembic to replace the current Point Cache.
Added subscriber: @lemenicier_julien
Added subscriber: @MaciejJutrzenka
Can we have also option of adding moddifier instance. and what it does it let's as choose... alembic file. it reads attribute like orient, Scale.. and we also choose what is the instance object. it can be collection or object. And that is how we could have instancing based on pointcloud. with is very very usefull.
Summarry:
Changed status from 'Confirmed' to: 'Archived'
@MaciejJutrzenka This is not the place to ask for new features.
I'm closing this task, as my concern about using Alembic for such caches hasn't been replied to in 1½ years.
Since Lukas did think about things and wrote down some designs, I do feel that this is still useful information, so I've added a link to my personal Alembic page on the wiki so that it's not forgotten.
Removed subscriber: @xuekepei
Added subscriber: @jeremybep