Multigrid

Constraints in Obi are solved only up to a level of accuracy, determined by the amount of substeps used by the solver and the amount of iterations per substep. This means a small error always remains in each individual constraint. If you have few constraints this is typically not a problem, however, small errors in every constraint in a large network amount to large global error.

This is particularly problematic for constraints that hold particles together, keeping the overall shape/structure of an actor: structural constraints, like distance and stretch/shear. Any error in them is clearly visible as unwanted stretching. Increasing the amount of iterations reduces the error very slowly, since each constraint iteration only propagates corrections to the ones immediately adjacent to it. Increasing the amount of substeps works better, but in some cases dozens of substeps are required for acceptable results.

Dresses with 4000 particles each, 2 substeps. Red dress, no multigrid. Green dress, 3 multigrid levels.

Multigrid solvers deal with this by working at multiple resolutions: instead of solving the original network of constraints multiple times, they create multiple versions of it with progressively fewer constraints/lower resolution that we'll call levels. Then they successively solve each level, from coarse to fine, using the solution to the current level as a starting point for the next one. Thanks to this, constraint corrections propagate a lot faster across the actor and stretching is greatly reduced even at low substep/iteration counts.

Multigrid level 4
Multigrid level 3
Multigrid level 2
Multigrid level 1
Original constraint network

How to use

The amount of multigrid hierarchy levels generated is determined by the rope/rod blueprint or cloth blueprint, so each actor can use a different amount of multigrid levels.


You can globally cap the amount of levels used by setting the solver's "Max Levels" parameter, under the "Constraint Settings" foldout: only the finest "Max Levels" ones will be used for all actors being simulated by the solver.


Once you've chosen the amount of levels generated by your blueprint, you can enable multigrid in your actor's inspector, for distance and stretch/shear constraints.

External constraints

Solving structural constraints using a coarse-to-fine multigrid scheme works well, but has one weakness: coarse levels know nothing of constraints affecting individual particles in the finer levels (such as collisions or pin constraints) so they will ignore them. As a result, structural constraints tend to overpower these external constraints, since they're evaluated at every multigird level while external ones are only evaluated at the finest level.

The solution to this is to not only prolong solutions from coarse levels to fine levels: do an additional fine-to-coarse pass, restricting external constraints so that coarse levels are aware of them.

In the ObiSolver component you'll find an "external iterations" parameter that determines how many times per substep external constraints are evaluated for coarser multigrid levels.