Soft Bodies

Introduction

Realistic deformations play an important role in computer graphics, games, simulations and VR environments.

Soft body simulations are used to change an object shape, when external forces are applied.

The computation of physically accurate deformation of objects when VR users uses hands controllers to interact is a liturgy, which requires much computation power. Only a few applications and simulations use soft body deformation due to computation power needed.


MAGES™ SDK & Soft bodies

In MAGES™ SDK, we provide a novel soft mesh deformation algorithm suitable for Virtual Reality interaction and collaboration.

The soft deformation algorithm is based on shape matching techniques and particle based spring mass soft body simulations. Our particle-based soft body algorithm is different from the state of the art because it provides easy control of the particles as physical objects and a center point, which controls the entire soft body position.

Velocity based interaction can be applied directly to our particles while as physical objects can interact also with the environment.

Our Virtual Reality interaction system uses velocity base approach providing the ability to pick up, hold and drop objects. Due to our soft body particles’ nature, this interaction can be applied directly.


Real time soft mesh deformations

With the use of term soft body, we mean a mesh that can change its initial vertices position when interacting with other physical meshes. Our main idea of creating a soft body physics algorithm is based on three main categories:

  1. Clustering

    The term clustering describes how each vertex on our mesh being grouped in another object that is used to calculate its deformation.

  2. How physics are applied

    For the soft bodies to achieve some deformation, physics should be applied. To apply physics in our soft bodies efficient and with good performance, we apply them to the clusters that we used to group all the vertices.

  3. Mesh deformation

    Finally, we have to calculate the mesh deformation. The resulting deformation derives from the Clustering transformation after the physics calculation. This transformation has an effect on our mesh vertices.


Soft bodies Interaction In VR

In virtual reality environments, the user can utilize hand controllers or other devices to interact with virtual objects. In this chapter, we provide a method on how this interaction can be performed based on physics properties.

We focus on how this interaction can be done by pickup and drop an object or physically interact with it. Then, we use this method to interact with our soft body mesh.

  • Pickup objects

    With the use of VR controller, the user is able to pick a virtual object and move it according to the laws of physics. The object is not able to pass through another object and normally stops, slides around it or pushes it.

  • Physical interaction

    The user is able to use the VR controllers to interact with object physically. For example, the user is able to push an object.

  • Interact with soft body

    To interact with a soft body mesh, we use both of the above methods. The user is able to grab a soft body mesh or physically interact with it.


How-To

To create a soft body interaction, you need to select a softbody Simulation Method and attach it to the object you want to be deformable. You can select the most suitable by Clicking Add Component and navigating to MAGES → Physics → Softbodies.

As of right now we have 2 different simulation methods both supporting skinned and static meshes. Below there is a short description and the properties of each available method:


Spring Mass

This method is based on a spring mass particle simulation with shape matching constraints. It is suitable for all kinds of simulation both for skinned and static meshes, producing visually pleasing results. You can select this method by clicking Add Component, navigating to MAGES → Physics → Softbodies and choosing either SpringMass Softbody for static meshes, or Skinned SpringMass Softbody for skinned meshes.

SpringMass Softbody

This will attach 2 scripts to the object, the Softbody SpringMass (Responsible for the particle behavior) and the Softbody SpringMass Skinner (Responsible for deforming the mesh based on the particle positions). Below are the properties of each script and what they do.

Image Showing the Inspector of the Simulation Part for the Softbody Spring Mass

Property

Description

Mesh mesh

The mesh we want to softbodify. If not assigned this object’s mesh will be used.

Material material

The material to use for the mesh. If left empty this object’s material will be used.

List<Collider> exclusionColliders

A list of colliders representing the areas we do not want to make deformable. If left empty the whole mesh will be deformable.

bool showParticleConnections

Visual debugging with gizmos for connections between particles while in editor.

bool showParticleConnectionsToCenter

Visual debugging with gizmos for particle connections to the object’s center while in editor.

float stiffness

The stiffness of the softbody springs. Increasing this value will make for a harder to deform object.

float damper

The damper of the softbody springs. Decreasing this value will make for a more bouncy object.

float tolerance

The spring tolerance. Large values will make for permanent deformations instead of elastic.

float particleMass

The mass of each particle.

float angularDrag

The angular drag of each particle.

bool useGravity

Wheter to calculate the gavity per particle (when enabled) or to calculate it based on the rigidbody of the object’s center (when disabled). Leave disabled for increased simulation stability.

PrimitiveType particleShape

The collision shape of each particle.

float particleRadius

The global scale/radius of the particles.

bool allowParticleSelfCollision

Can the particles collide with each other?.

int maxNumParticles

The maximum number of particles that can be generated.

float particleDistance

The minimum distance between two particles. Decreasing this value will increase realism in exchange for performance.

float particleConnectionDistance

The max distance of two connected particles. Increasing this value will increase realism in exchange for performance. It must be greater than particleDistance

Image Showing the Inspector of the Skinning Part for the Softbody Spring Mass

Property

Description

Mesh mesh

The mesh we want to softbodify. If not assigned this object’s mesh will be used.

List<Collider> exclusionColliders

A list of colliders representing the areas we do not want to make deformable. If left empty the whole mesh will be deformable.

bool showAffectedVertices

Visual debugging with gizmos for the affected vertices of each particle.

bool showAffectionRadius

Visual debugging with gizmos for the affection radius of each particle with spheres.

ParticleAttachMethods particleAttachMethod

The way the particles will be attached to our softbody. Will they become children of the softbody (ParentTransform option), or only connect with physics (SpringConnect option) to it.

float fallOffRadius

The radius where the falloff will begin. Until that point the affection value will be 1.

float particleAffectionRadius

The radius where the falloff will end.

FallOffCurves fallOffCurve

The curve to use as falloff.

AnimationCurve customFalloff

If the falloff curve is set to Custom then this defines the custom curve. Otherwise, it is not used.

Skinned SpringMass Softbody

This will attach 2 scripts to the object, the Softbody SpringMass (Responsible for the particle behavior) and the Softbody SpringMass Skinner (Responsible for deforming the mesh based on the particle positions). Below are the properties of each script and what they do.

Image Showing the Inspector of the Simulation Part for the Skinned Softbody Spring Mass

Property

Description

Mesh mesh

The mesh we want to softbodify. If not assigned this object’s mesh will be used.

Material material

The material to use for the mesh. If left empty this object’s material will be used.

List<Collider> exclusionColliders

A list of colliders representing the areas we do not want to make deformable. If left empty the whole mesh will be deformable.

bool showParticleConnections

Visual debugging with gizmos for connections between particles while in editor.

bool showParticleConnectionsToCenter

Visual debugging with gizmos for particle connections to the object’s center while in editor.

float stiffness

The stiffness of the softbody springs. Increasing this value will make for a harder to deform object.

float damper

The damper of the softbody springs. Decreasing this value will make for a more bouncy object.

float tolerance

The spring tolerance. Large values will make for permanent deformations instead of elastic.

float particleMass

The mass of each particle.

float angularDrag

The angular drag of each particle.

bool useGravity

Wheter to calculate the gavity per particle (when enabled) or to calculate it based on the rigidbody of the object’s center (when disabled). Leave disabled for increased simulation stability.

PrimitiveType particleShape

The collision shape of each particle.

float particleRadius

The global scale/radius of the particles.

bool allowParticleSelfCollision

Can the particles collide with each other?.

int maxNumParticles

The maximum number of particles that can be generated.

float particleDistance

The minimum distance between two particles. Decreasing this value will increase realism in exchange for performance.

float particleConnectionDistance

The max distance of two connected particles. Increasing this value will increase realism in exchange for performance. It must be greater than particleDistance

Image Showing the Inspector of the Skinning Part for the Skinned Softbody Spring Mass

Property

Description

Mesh mesh

The mesh we want to softbodify. If not assigned this object’s mesh will be used.

List<Collider> exclusionColliders

A list of colliders representing the areas we do not want to make deformable. If left empty the whole mesh will be deformable.

bool showAffectedVertices

Visual debugging with gizmos for the affected vertices of each particle.

bool showAffectionRadius

Visual debugging with gizmos for the affection radius of each particle with spheres.

ParticleAttachMethods particleAttachMethod

The way the particles will be attached to our softbody. Will they become children of the softbody (ParentTransform option), or only connect with physics (SpringConnect option) to it.

float fallOffRadius

The radius where the falloff will begin. Until that point the affection value will be 1.

float particleAffectionRadius

The radius where the falloff will end.

FallOffCurves fallOffCurve

The curve to use as falloff.

AnimationCurve customFalloff

If the falloff curve is set to Custom then this defines the custom curve. Otherwise, it is not used.


Lightweight

This method is based on a spring mass particle simulation with shape matching constraints. It is suitable for all kinds of simulation both for skinned and static meshes, producing visually pleasing results. You can select this method by clicking Add Component, navigating to MAGES → Physics → Softbodies and choosing either SpringMass Softbody for static meshes, or Skinned SpringMass Softbody for skinned meshes.

Lightweight Softbody

This will attach 2 scripts to the object, the Softbody SpringMass (Responsible for the particle behavior) and the Softbody SpringMass Skinner (Responsible for deforming the mesh based on the particle positions). Below are the properties of each script and what they do.

Image Showing the Inspector of the Simulation Part for the Softbody Spring Mass

Property

Description

Mesh mesh

The mesh we want to softbodify. If not assigned this object’s mesh will be used.

Material material

The material to use for the mesh. If left empty this object’s material will be used.

List<Collider> exclusionColliders

A list of colliders representing the areas we do not want to make deformable. If left empty the whole mesh will be deformable.

float returnSpeed

Increasing this will make the particles return faster to their original position and therefore the object will appear harder.

float maxDeformation

The max distance from its original position each particle can go. If set to negative value the max distance limit is disabled.

float particleMass

The mass of each particle.

float particleDrag

The drag of each particle. If the softbody is jittering then increase this value.

float angularDrag

The angular drag of each particle.

bool useGravity

Whether to calculate the gravity per particle (when enabled) or to calculate it based on the rigidbody of the object’s center (when disabled). Leave disabled for increased simulation stability.

PrimitiveType particleShape

The collision shape of each particle.

float particleRadius

The global scale/radius of the particles.

bool allowParticleSelfCollision

Can the particles collide with each other?.

int maxNumParticles

The maximum number of particles that can be generated.

float particleDistance

The minimum distance between two particles. Decreasing this value will increase realism in exchange for performance.

float particleConnectionDistance

The max distance of two connected particles. Increasing this value will increase realism in exchange for performance. It must be greater than particleDistance

Image Showing the Inspector of the Skinning Part for the Lightweight Softbody

Property

Description

Mesh mesh

The mesh we want to softbodify. If not assigned this object’s mesh will be used.

List<Collider> exclusionColliders

A list of colliders representing the areas we do not want to make deformable. If left empty the whole mesh will be deformable.

bool showAffectedVertices

Visual debugging with gizmos for the affected vertices of each particle.

bool showAffectionRadius

Visual debugging with gizmos for the affection radius of each particle with spheres.

ParticleAttachMethods particleAttachMethod

The way the particles will be attached to our softbody. Will they become children of the softbody (ParentTransform option), or only connect with physics (SpringConnect option) to it.

float fallOffRadius

The radius where the falloff will begin. Until that point the affection value will be 1.

float particleAffectionRadius

The radius where the falloff will end.

FallOffCurves fallOffCurve

The curve to use as falloff.

AnimationCurve customFalloff

If the falloff curve is set to Custom then this defines the custom curve. Otherwise, it is not used.

Skinned Lightweight Softbody

This will attach 2 scripts to the object, the Lightweight Softbody (Responsible for the particle behavior) and the Softbody Light Skinner (Responsible for deforming the mesh based on the particle positions). Below are the properties of each script and what they do.

Image Showing the Inspector of the Simulation Part for the Skinned Softbody Spring Mass

Property

Description

Mesh mesh

The mesh we want to softbodify. If not assigned this object’s mesh will be used.

Material material

The material to use for the mesh. If left empty this object’s material will be used.

List<Collider> exclusionColliders

A list of colliders representing the areas we do not want to make deformable. If left empty the whole mesh will be deformable.

float returnSpeed

Increasing this will make the particles return faster to their original position and therefore the object will appear harder.

float maxDeformation

The max distance from its original position each particle can go. If set to negative value the max distance limit is disabled.

float particleMass

The mass of each particle.

float particleDrag

The drag of each particle. If the softbody is jittering then increase this value.

float angularDrag

The angular drag of each particle.

bool useGravity

Whether to calculate the gravity per particle (when enabled) or to calculate it based on the rigidbody of the object’s center (when disabled). Leave disabled for increased simulation stability.

PrimitiveType particleShape

The collision shape of each particle.

float particleRadius

The global scale/radius of the particles.

bool allowParticleSelfCollision

Can the particles collide with each other?.

int maxNumParticles

The maximum number of particles that can be generated.

float particleDistance

The minimum distance between two particles. Decreasing this value will increase realism in exchange for performance.

float particleConnectionDistance

The max distance of two connected particles. Increasing this value will increase realism in exchange for performance. It must be greater than particleDistance

Image Showing the Inspector of the Simulation Part for the Skinned Softbody Spring Mass

Property

Description

Mesh mesh

The mesh we want to softbodify. If not assigned this object’s mesh will be used.

List<Collider> exclusionColliders

A list of colliders representing the areas we do not want to make deformable. If left empty the whole mesh will be deformable.

bool showAffectedVertices

Visual debugging with gizmos for the affected vertices of each particle.

bool showAffectionRadius

Visual debugging with gizmos for the affection radius of each particle with spheres.

ParticleAttachMethods particleAttachMethod

The way the particles will be attached to our softbody. Will they become children of the softbody (ParentTransform option), or only connect with physics (SpringConnect option) to it.

float fallOffRadius

The radius where the falloff will begin. Until that point the affection value will be 1.

float particleAffectionRadius

The radius where the falloff will end.

FallOffCurves fallOffCurve

The curve to use as falloff.

AnimationCurve customFalloff

If the falloff curve is set to Custom then this defines the custom curve. Otherwise, it is not used.


Saving Utilities

All the skinning scripts have a tab called Saving Utilities. By selecting it you will a button in order to Save the softbodified mesh as an asset. Simply press it and choose a path in the project’s Assets directory as well as a suitable name to save the softbodified mesh as.

Network Limitations

Limitations

Due to the lack of an authoritative server in the system the MAGES SDK use, there are some limitations in the softbody interactions when in cooperative environments. The softbody physics will be handled by the machine of the client who last grabbed a particle of the softbody. The other clients will not be able to interact, until grabbing some particle and therefore taking authority of the simulation to their machine.

Setup

Warning

Photon PUN2 must first be imported, if not already done, in order to add network support. Use the MAGES Helper menu to import it.

In order to add multiplayer support to a softbody object simply press the Configure for Network button found at the end of the simulation script of the softbody.

Image Showing the Configure for network button found in the simulation script of the softbody.

In order to limit the network bandwidth you may increase the Movement and Rotation threshold of the MAGES Sync Transform Photon and the Net Multi Transform Photon script. Keep in mind that as you increase these values the more the max difference in transform the softbody may have between devices will be.