ObiSolver

The ObiSolver component is arguably the most important component in Obi. It is responsible for simulating particle physics and enforcing constraints. Three important things to remember about solvers:

  • They can be added to any GameObject in your scene and there can be more than one solver working simultaneously in the same scene.
  • Every actor needs to have a solver up its hierarchy in order to get updated and rendered.
  • Each solver is completely independent from other solvers. Therefore, actors being updated by different solver won't interact / collide with each other. Only actors in the same solver will react to each other.

Solvers always perform the simulation in local space. This means that translating, rotating or scaling the solver will rigidly transform the simulation as a whole.

You can inject a percentage of the solver linear/rotational movement back into the simulation, in the form of inertial forces. For instance, you might want to control how much of the overall character movement will affect the clothing simulation. For this purpose, solvers expose two parameters to independently control linear and rotational inertial forces (see below).

Solver

The solver inspector is organized in multiple foldable panels, each one contains parameters affecting one specific aspect of the solver's behavior.

Solver settings

These settings control how the solver works internally:

Backend

Which simulation backend to use. See the backends page for more information.

Mode

The solver can simulate in 2D or 3D mode. In 2D mode, simulation only happens in the XY plane.

Interpolation

Interpolation mode used to render particles. None is faster to calculate, but Interpolate and Extrapolate will give more visually pleasing results. However, they will introduce a 1-frame delay between the actual physical location of particles and the position they're rendered at. Keep this in mind when using interpolation or extrapolation around other objects in the scene. If you have rigidbodies interacting with Obi, it is generally a good idea to use the same interpolation settings for both the Obi solver and the rigidbodies.

None:
Results of the last simulation step are directly rendered. Since physics simulation is updated at a fixed frequency but rendering uses a variable frequency, this can result in stutter (specially when the project's timescale is < 1).

Interpolate:
Results of the last simulation step and the second-to-last simulation step are interpolated and rendered. This results in smooth motion, but is slightly costlier and causes rendering to be 1 frame behind simulation.

Extrapolate:
Results of the last simulation step are extrapolated to the future. This results in smooth motion, but is slightly costlier and causes simulation to be 1 frame behind rendering.

Synchronization

Determines how simulation and rendering are sychronized. In asynchronous mode, the main thread will wait for the current simulation step to finish at the start of the next physics step. This allows physics and rendering to happen concurrently, and unless simulation takes more than one frame to complete the main thread won't be stalled. This yields better performance at the cost of rendering being at least one frame behind simulation.

In synchronous mode, the main thread waits for the current simulation step to finish before rendering the current frame, as a result, physics and rendering happen sequentially. This yields worse performance, but every frame renders the latest available simulation results.

In synchronous fixed mode, simulation kicks off and the main thread waits for it to finish in FixedUpdate(). This yields the tightest integration with Unity's built-in physics. However, it also yields the wost performance out of all 3 methods since it locks the main thread -like synchronous mode- and has the potential to do so multiple times per frame in cases where Fixedupdate() is called multiple times.

See update loop for an in-depth explanation of how Unity's physics update loop works and how the different solver synchronization modes are bolted onto it.

Synchronous mode. Simulation for the current frame must finish before rendering starts. Each frame takes 11 ms.
Asynchronous mode. Time spent in simulation extends beyond the end of the frame, while rendering is taking place. Each frame takes 7 ms.

Substeps

How many times to update the simulation during each physics step. This is Obi's main quality vs performance dial: lower substep counts will result in cheaper, faster simulations that look too elastic due to spurious compliance. Higher substep counts will result in costlier, snappier, higher quality simulations.

For an in-depth explanation of how the engine works internally and how substeps affect its output, see simulation.

Max steps per frame

Maximum amount of physics steps can be simulated per frame. Similar to Unity's max allowed timestep, but only affects the solver's simulation instead of all physics in the project.

Simulation settings

Various global simulation parameters regarding external forces/accelerations such as gravity, wind, damping, inertia, etc:

Gravity Space

Whether to apply gravity in the solver's local space (Self) or in world space (World). If set to "Self", the direction of gravity will rotate together with the solver.

Gravity

Direction and magnitude of gravity applied to particles in this solver.

Sleep threshold

Any particle with a kinetic energy below this value will be freezed in place. This is useful when you don´t want minuscule variations in velocity or force to perturb an actor, making it look like its jittering or moving very slowly. Set it to zero if you want your particles' positions to be affected by any force that acts upon them, however small it may be.

Max velocity

Particle velocities will be clamped to not exceed this value, limiting how fast they can move.

Max angular velocity

Particle angular velocities will be clamped to not exceed this value, limiting how fast they can rotate.

Damping

Velocity damping applied to particle velocities. Increase it to reduce their kinetic energy.

World linear inertia scale

Controls how much of the world-space linear inertia of the solver transform is applied to the particles. Values range from 0 (none) to 1 (100% of it).

Moving solver containing a piece of cloth with linear inertia scale set to 1. Notice how the cloth continues moving forward when the solver abruptly stops, and how it is launched backwards when the solver resumes its movement.

World angular inertia scale

Analogous to the previous property, but controls angular inertia (rotations) instead of linear inertia (translations). Note that centrifugal and coriolis forces are accounted for.

Rotating solver containing a piece of cloth with angular inertia scale set to 1. Note how centrifugal forces lift it up while rotating.

Simulate when invisible

Should this solver keep the simulation going when invisible to all cameras? Keep this enabled if your simulation needs to be updated at all times, disable it to improve performance when multiple solvers exist in the scene but they are not visible at all times.

Use limits

By default, the simulation performed by a solver is unbounded: particles can go anywhere. Enabling this checkbox adds box-shaped limits to the solver, that particles cannot leave.

Kill off limits particles

Any particles created by emitters (either fluid or granular) will be killed and returned to their emitter's pool as soon as they touch the solver's limit box.

Boundary limits

Allows you to specify the center and extents of the solver's limits box.

Constraint settings

You can globally enable/disable each constraint type for all actors being managed by the solver. Disabling constraints this way (as opposed to disabling constraint components for individual actors) will allow the solver to completely skip any calculations related to that specific constraint type.

For instance, if you disable collision constraints and particle collision constraints, the entire collision detection pipeline is skipped. This allows you to customize what's being done under the hood and get rid of unnecessary overhead.


Most constraints in Obi exposes 3 parameters in the solver:

Enabled (checkbox right next to the constraint's name)

Are these constraints updated at all? By default all constraint types are enabled, altough this is rarely what you want for production-ready simulations. You should disable any constraints that are not critical for the final look of your simulation.

Iterations

How many times per substep should these constraints be evaluated? A high iteration count will keep the simulation closer to the ground-truth solution. Keep it low if these constraints aren`t very important for your particular purpose and you want to get better performance. The default is 1.

In each iteration, constraints are evaluated in the order they were created (which is determined by each specific ObiActor) and each constraint “sees” the adjustments made by all previous constraints. This ensures quick convergence, so few iterations are enough for good results. However, results are order-dependent, so in low-budget situations (few particles, few iterations and/or large timesteps) this can result in visible patterns in particle arrangement. For those of you a bit on the technical side, iterations implement a Gauss-Seidel solver scheme.

Smoothing iterations

In each smoothing iteration, all constraints are evaluated but their adjustments are not immediately applied to the particles. Instead, they are mass-weighted, stored, and then used to adjust particle positions after they've been all calculated. This results in an order-independent smoothing of constraint error, however more smoothing iterations are needed for “hard” constraints as it converges much more slowly than regular iterations. For this reason, they're often used alongside "regular" iterations: 1 regular iteration to quickly reduce the error, 1 or 2 smoothing iterations to spread it out evenly. For technical users: smoothing iterations implement a Mass-Splitting solver scheme.

The following images show a rope that's been stretched way past its rest length, using regular and smoothing iterations for distance constraints. Using regular iterations only (left), a clumping pattern in particle placement caused by order-dependent evaluation is clearly visible. Using smoothing iterations only (right) all particles are evenly spaced, but the rope sags a bit more due to reduced convergence speed.

Stretched rope using 5 distance constraint iterations.
Stretched rope using 5 distance constraint smoothing iterations.

Here's another example: some rigidbodies on a trampoline. Cloth tension is mapped to a color gradient for visualization purposes. Using regular iterations only (left), tension is unevenly distributed over the cloth's surface, resulting in a noisy color pattern. Using smoothing iterations only (right) tension is evenly distributed, but the cloth is more elastic due to reduced convergence speed.

Cloth trampoline using sequential distance constraint evaluation.
Cloth trampoline using parallel distance constraint evaluation.

Here's a list of all built-in constraints in Obi. Click on their names to see a detailed description of what they do and their parameters:

Multigrid constraints

Multigrid accelerates convergence and minimize spurious stretching of distance and stretch/shear constraints (see below).

Collision constraints

Collision constraints try to keep particles outside of colliders. High iteration counts will yield more robust collision detection when there are multiple colllisions per particle.

Particle collision constraints

Identical to collision constraints, but for when collisions happen between particles.

Distance constraints

Each distance constraint tries to keep two particles at a fixed distance form each other. These are responsible for the elasticity of cloth and ropes. High iteration counts will allow them to reach higher stiffnesses, so your ropes/cloth will be less stretchy.

Pin constraints

A pin constraint will apply forces to a particle and a rigidbody so that they maintain their relative position. They are created and used by dynamic attachments. High iteration counts will reduce the amount of drift at the pin location, making the attachment more robust.

Pinhole constraints

A pinhole constraint will apply forces to a rope element and a rigidbody so that they maintain their relative position. They are created and used by ObiPinhole components. High iteration counts will reduce the amount of drift at the pinhole location, making it more robust.

Stitch constraints

Stitch constraints try to keep 2 particles on top of each other. They are created and used by stitchers. High iteration counts will reduce the amount of drift at the stitch location, making it more robust.

Volume constraints

Each volume constraint takes a group of particles positioned at the vertices of a mesh, and tries to maintain the mesh volume. Used to inflate cloth and create balloons. High iteration counts will allow the ballons to reach higher pressures, and keep their shape more easily.

Aerodynamic constraints

Used to simulate wind.

Bend constraints

Each bend constraint will work on three particles, trying to get them in a straight line. These are used to make cloth and ropes resistant to bending. As with distance constraints, high iteration counts will allow them to reach higher stiffness.

Skin constraints

Skin constraints are used to keep skeletally animated cloth close to its skinned shape. They are mostly used for character clothing. Generally 1-2 iterations are enough for skin constraints.

Density constraints

Each density constraint tries to keep the amount of mass in the neighborhood around a particle constant. This will push out particles getting too close (as that would increase the mass) and pull in particles going away (which results in surface tension effects). Used to simulate fluids. High iteration counts will make the fluid more incompressible, so it will behave less like jelly.

Shape matching constraints

Each shape matching constraint records a rest shape for a group of particles, then adjusts their positions so that they maintain this shape as closely as possible. These are used by softbodies.

Stretch/shear constraints

Stretch/shear constraints adjust the position of a pair of particles along the axis of a reference frame, determined by a rotation quaternion. These are used by rods and bones.

Bend/Twist constraints

Bend/twist constraints adjust the orientation of a pair of particles to prevent both bending and twisting. These are used by rods and bones.

Memory budget

These settings allow you to control the amount of memory allocated by a solver:

Max Foam Particles

Maximum amount of advected particles that can be simultaneously simulated by the solver.

Max Particle Interactions

Amount of entries allocated per particle to store the indices of interacting particles around it (colliding with it or part of its density neighborhood).

Max Particle Contacts

Amount of contacts against colliders, contacts against other particles, or spatial query results each particle can have.