Cloth Rendering

At the end of each frame, after rope simulation has been performed, rendering takes place: the ObiClothRenderer/ObiTearableClothRenderer/ObiSkinnedClothRenderer components will update the cloth mesh to keep it in sync with the particle based simulation.

Internally, updating the cloth mesh this requires two steps:

  • Move each mesh vertex to the position of the corresponding particle. Optionally, copy particle color to vertex color (for shader use).
  • Update the mesh's tangent space (normal and tangent vectors).

Obi will let you choose between several following modes to update the mesh's tangent space:

CopyNormalsFromSimulation (normals only)

Every frame, Obi will calculate area-weighted normals for each particle in the cloth. These are used by some constraints, such as aerodynamics. This mode copies the normal of each particle to the corresponding mesh vertices. All it involves is copying existing data from one array to another, so this is the cheapest mode.

RecalculateNormalsFromMesh (normals only)

Calls Unity's Mesh.RecalculateNormals. Moderately expensive, results in slightly higher-quality normals than CopyNormalsFromSimulation.

RecalculateNormalsAndTangentsFromMesh (normals and tangents)

Calls Unity's Mesh.RecalculateNormals and Mesh.RecalculateTangents. The resulting normals are the same as when using RecalculateNormalsFromMesh, but this recalculates tangents too.

TransformNormalsAndTangents (normals and tangents)

Most expensive mode, best quality. Calculates a per-vertex matrix that transforms the mesh's rest normals/tangents to the deformed tangent space. Use this if your mesh contains hand-crafted normal seams or tangents that you don't want to change during simulation.