Projective Dynamics Simulation Zone Design

It’s been a while since I contributed to Blender and things have changed considerably so hopefully this is the right way…

I’ve been chipping away at my Simulation Zone (Dan-Eicher/projective-dynamics: Projective Dynamics Simulation Zone - projective-dynamics - Blender Projects) and have finally reached a point where it (somewhat) works and probably needs some bikeshedding as I’m not too sure how the whole Geometry Nodes thing is supposed to work so can’t really tell if some of the stuff I’m doing is correct or not

Anyhoo, what it actually is: I’ve (well, the daffy robots) implemented the Projective Dynamics library (Projective Dynamics: Fusing Constraint Projections for Fast Simulation), using Eigen as the base to do all the fancy constraint solving math, and now we’re in the process of integrating individual constraints/forces as nodes as a sort of Physics Toolkit where one can construct their own ‘physics’ simulations, stuff like cloth, soft body, self/multi-object collision, &etc – you know, the fun stuff.

UI feedback would probably be the most helpful as everything in just kind of dumped into the ‘Simulation’ sub-menu – which, I’m guessing, is probably wrong – or, perhaps, a gentle “you’re doing it all wrong, what were you even thinking?”

3 Likes

You might want to share some pictures or videos of the changes you’ve made. I don’t assume many of the people who would like to give feedback are also willing to/capable of compiling your Blender fork themselves :slight_smile:

1 Like

Also you seems to didn’t pushed anything in your branch

Maybe this is the correct branch link? Dan-Eicher/projective-dynamics: Projective Dynamics Simulation Zone - projective-dynamics - Blender Projects

Can you just change the link in the first post to the correct one?

In the geometry nodes module we’ve been working on a softbody simulation feature for a while, with the added goal of establishing a general workflow for declarative workflows that can be used for other simulation systems and solvers as well. I had a talk at the last Blender conference about the current state of things.

The gist of it is that instead of running a simulation on a single geometry (mesh) we declare simulation targets in “bundles” which can be combined with other behaviors. This has several advantages, among others it avoids baking to attributes for dynamically changing fields (forces for example). The solver node evaluates the bundle content and evaluates the fields when needed.

Our current solver node is a generic XPBD implementation (physics-solver branch). XPBD is more widely used and special constraint formulations for Cosserat rods are easier to find, which is important for our immediate goal of implementing hair dynamics.

A dedicated PD solver could be an interesting option, especially if it uses an existing library. I’ve experimented with PD at one point based on the “Cosserat Rods with Projective Dynamics” paper by Soler, but shelved the idea for the time being in favor of getting a functioning system first. The main issue i had was that the global solver relies on constraint gradients and handling hard constraints isn’t trivial. To my knowledge the ADMM technique specifically addresses this by alternating soft and hard constraint solver steps (“Interactive Hair Simulation on the GPU using ADMM”, Daviet).

All that being said, i personally have a strong aversion against AI generated code. I don’t know if Blender has a policy on this topic yet.

8 Likes

Our admins discussed the topic of AI code contributions here:

First, as a general rule, I’m using AI as a tool to compensate for my complete lack of any reasonable math skills and/or being much too lazy to actually dig in and write the code myself and I keep it on a pretty tight leash based on a carefully researched and designed plan.

This isn’t really a softbody simulator (not at least without tetrahedral meshes which would probably require some surgery to BMesh) but a way to define the surface properties of meshes – under deformation, in collisions, etc… Sort of a shape-key replacement where you tell the mesh what it can and can’t do under external (or internal by way of the force nodes) disturbances.

My idea is you rig your mesh and then weight paint – or whatever is used now, been a long while since I’ve used Blender – the bony parts, the stretchy parts, the bouncy parts and use these to constrain the mesh in a ‘natural’ way to simulate whatever’s underneath the mesh like a muscle and skeletal system in a character. And, something which I think is kind of cool, you can also use the “Shape Constraint” to define things like dragon scales, the scales themselves keep their shape while the areas around them deform to adhere to the pose. Haven’t actually debugged that one yet so…

As to the bake vs. not bake, I wasn’t sure about that but we (me and the daffy robots) just did what the existing Simulation Zone does by plugging into the baking system while also using the Lazy Function to cache state across the frames like the Repeat zone uses. This could (probably) be made to run the constraint solver on each update and not bake the results but, dunno?

So… not a full program simulation but the building blocks of different constraint types to do a sort of “ghetto physics” on the meshes for whatever artistic reason. Ironically, it should also be able do a reasonable hair dynamics.

Oh, and the “existing library” is just Eigen, that’s what does all the heavy lifting and it’s doing some sort of zero-copy matrix thing, allegedly, for efficiency. The solver was surprisingly easy to implement using Eigen’s built-in functionality. Plus, adding new constraint types is trivial, I just started with the ones from the paper which would work without converting to tetrahedral meshes.

Our AI overlords say “The most pragmatic path forward would probably be to engage with their existing XPBD work rather than trying to introduce a competing solver architecture” so, who knows?

–edit–

I did some more interrogation of the daffy robot and this is a more concise description of (one of) the intended use cases:

How This Would Work

Your pipeline would be:

  1. Armature deforms the mesh (standard skinning/deformation)
  2. PD simulation “fixes” the artifacts using constraints:
    - Stretch constraints prevent unnatural stretching from skinning
    - Bending constraints smooth out creases
    - Volume/area constraints prevent collapsing
    - Collision constraints prevent self-intersection

This approach gives you physically-based shape keys that automatically work for any pose - exactly what the paper’s “generality” criterion was designed for. You’re not doing full cloth simulation, you’re using PD as an intelligent smoothing/correction filter on top of traditional rigging.

2 Likes

The problem with this is that it means you will not be able to fix bugs, make improvements and maintain the code well. Generally getting something from a prototype to something reliable is the most difficult and where most developer time is spent. And it’s also what AI is not good at.

I think it’s fair for other developers to then say that they are not willing to spend time reviewing the code and doing the hard work of making it reliable, while you were only willing to do the easy first steps.

19 Likes