Simulation Topics ================= .. include:: physical_simulation.include.rst .. include:: simulation_objects.include.rst .. include:: attachments.include.rst .. include:: collisions.include.rst .. include:: integrator.include.rst Real World Units ---------------- Ziva VFX uses real-world scientific units for most parameters: .. list-table:: :header-rows: 1 * - Attribute - Units * - Length - Meters [m] * - Time - Seconds [s] * - Mass - Kilograms [kg] * - Material Stiffness - N/m :sup:`2` = Pa = kg/(s :sup:`2` m) * - Fiber Strength - N/m :sup:`2` * - Attachment Stiffness - N/m :sup:`3` * - Density - kg/m :sup:`3` Real world values for many materials are available, and can be found in places such as `on Wikipedia `_ and `other sources `_. .. include:: materials.include.rst .. _sec-volume-preservation: Volume Preservation ------------------- Volume preservation is visually important for the simulation of solids (tissues). There are multiple ways to control tissue volume preservation. First, there is the **Poisson's Ratio** parameter on the :ref:`sec-zMaterial` node. Poisson's ratio defines the relative change in volume due to stretching, and successfully controls volume preservation under small deformations. Mathematically, it does not apply to large deformations, although it is often used in practice for that purpose. Values near 0.5 cause the simulated material to act unnaturally stiff, so it is not recommended to set the Poisson's Ratio too high (a good rule of thumb is to stay below 0.45). One can also preserve volume under large deformations via the **volume conservation** parameter on the :ref:`sec-zMaterial` node. The higher this setting, the more the tissue preserves volume. The volume conservation parameter is independent of Young's modulus, and typical effective values may be 10 :sup:`2` to 10 :sup:`7` times larger than the Young's modulus. Alternatively, the **compression resistance** parameter on the :ref:`sec-zTissue` node can be used to prevent compression, but permit expansion. The compression resistance strength scales with the Young's modulus (stiffness) and typical effective values are in the 1000's or 10,000's. .. note:: Large values for compression resistance may cause simulation instabilities, requiring more substeps or Newton iterations to resolve. The volume conservation setting is typically more stable. Using volume conservation or compression resistance makes it possible to simulate very soft materials. For example, try decreasing the Young's modulus to a very small value. With a sufficient level of volume conservation or compression resistance, you should see soft, goop-like behavior. Ziva VFX provides two physically-correct tools to manipulate the volume of tissues (and cloth): :ref:`sec-muscle-growth` and :ref:`sec-rest-scale`. Volume preservation is always applied *after* these volume manipulations have been applied. In other words, the volume that will be preserved is the volume of the tissue after rest scale and muscle growth have been taken into account. .. include:: muscles.include.rst .. include:: tetmeshing.include.rst Embedding Meshes into Tissues -------------------------------------- The tissues in our system are simulated as tetrahedral meshes. When you generate a tissue, its triangle mesh is automatically embedded into the generated tet mesh. Additional Maya triangle meshes can be embedded into our tissue tet mesh as well. This allows one to easily update the simulation (say, if the triangle model is refined at a later stage in the production). Our attachments, collisions and space-varying coefficients are authored on triangle mesh geometry. Our solver then transfers these values to the tissue tet mesh. As a result, editing volume data is no more difficult than painting the weights for a skinCluster. .. _sec-physical-effects: Physical Effects ---------------- Damping ^^^^^^^ Damping is the mechanism by which objects lose energy and slow down. Our plugin provides three kinds of damping, they are adjustable in the solver and attachment node. "Stiffness damping" primarily dampens high-frequencies (rapid vibrations, in space and/or time). It is useful to increase stability without damping the simulation too much. "Mass damping" is a non-physical damping, somewhat like being under water. It slows all motions equally. The "mass damping" is normally set to zero, and a small amount of "stiffness damping" is recommended in order to keep the simulation stable. "Attachment damping" dampens the oscillation caused by attachment, thus achieving energy dissipation more realistically. It helps return the dynamic simulation (backward Euler, BDF2, TR-BDF2) to equilibrium quickly. Attachment damping is applied to each attachment respectively. Inertial Damping ^^^^^^^^^^^^^^^^ Inertial damping is a non-physical effect used to enhance stability or handle non-physical inputs. It prevents tissues from 'feeling' inertia due to large-scale motions (including all affine modes: e.g. translation, rotation, shear, and scale). Tissues with inertial damping have no momentum from these modes, and effectively act quasi-static. However, they exhibit normal dynamics for higher-frequency components. Small-scale deformations still have all of their inertia, so elastic waves travel through objects normally. Using this, tissues can be subjected to extreme acceleration without flying apart. Inertial damping is very different from the mass and stiffness damping available on the zSolver node. It can be enabled on the zTissue node, but it is recommended to be turned off until needed. .. _sec-fields: Fields ^^^^^^ External forces can be applied to Tissue and Cloth objects using Maya Fields. You can use this functionality, for example, to model wind forces. Any field that can be modeled using Maya Fields can serve as external forces. Based on the size and material properties of your objects, you will likely have to adjust the Magnitude attribute of the Fields in your scene. For example, with a default PolySphere converted into a Tissue with default properties, an Air field requires a Magnitude of approximately 1,040,000 to counteract the acceleration due to gravity in the Ziva solver. .. _sec-pressure: Pressure ^^^^^^^^ Pressure (:ref:`sec-zMaterial`.pressure) applies external pressure to the surface of Cloth or Tissue objects. The pressure acts in the direction normal to the triangle mesh of the Cloth or Tissue, and the magnitude of the effect can be painted spatially. For example, pressure can be applied to cloth (fascia) that wraps over muscles, which will cause it to fill in any little valleys between the muscles. This will make the muscle geometry more pronounced. A similar effect can be achieved using tissues without any cloth objects. Model a layer of fat over the muscles as a tissue with an inner wall (the fascia) and an outer wall (the skin). Then, paint the pressure to zero on the skin and paint a negative pressure on the inner wall. This will cause the fat layer to shrink inwards and envelop the muscles. In many cases, such direct usage of pressure on tissues eliminates the need for cloth, and can significantly reduce the simulation time and model complexity. Pressure is given in units of :math:`N / m^2`. A value of 0.0 means no pressure. Positive values mean that the pressure is trying to compress the volume enclosed by the cloth or tissue, and negative values correspond to expansion. It is common to use relatively large values (for example, 100.0). As one point of reference, the extra pressure felt by an object at the bottom of a shallow (~1m) swimming pool would be approximately 10,000 :math:`N / m^2`. Pressure can be animated over time using :ref:`sec-zCloth`.pressureEnvelope or :ref:`sec-zTissue`.pressureEnvelope. This can be used, for example, to ramp up the effect over a few frames, rather than activate it abruptly in one frame. .. _sec-surface-tension: Surface Tension ^^^^^^^^^^^^^^^ This feature (:ref:`sec-zMaterial`.surfaceTension) adds a force that tries to minimize the surface area of an object while respecting elasticity and other forces. It can be applied to tissues or cloth. Effectively, this shrinks the object across its surface, but not in the interior. For example, if it is applied to an elastic cube, it will turn it to a spherical shape. This feature can be used in conjunction with pressure for tissues for shrink-wrapping a layer of fat around muscle geometry. The difference between pressure and surface tension is that pressure will suck the fat layer into the valleys between the muscles, whereas surface tension will make the fat layer stretch across the gaps in the muscle shapes. Usually, pressure and surface tension should be used together, perhaps by varying amounts on different locations on the model. In both cases, the effects can be painted to only affect the inner wall of the fat layer. It is possible to set surface tension to negative values. This will cause the triangle mesh to expand. Surface tension can be animated over time using :ref:`sec-zCloth`.surfaceTensionEnvelope or :ref:`sec-zTissue`.surfaceTensionEnvelope. .. figure:: images/surfaceTensionPressure.png :alt: Comparison between pressure and surface tension Comparison between pressure and surface tension. This scene has 1 star-shaped bone (grey) and 1 circular cloth (green). **Left:** undeformed configuration. **Middle:** Pressure is applied to the cloth, pushing it in towards the bone. **Right**: Surface tension is applied to the cloth. Unlike with pressure, the cloth does not enter into the "gaps" in the bone, but instead forms a small planar region spanning the "peaks" of the bone. .. _sec-rest-scale: Rest Scale ^^^^^^^^^^ Rest scale (:ref:`sec-zMaterial`.restScale) causes a cloth or tissue to shrink or enlarge uniformly in all directions. This is accomplished by scaling the "rest shape" of the object by the given amount, causing the object's internal elastic forces to deform the object into that scaled shape. For tissues, the entire volume enclosed by the tissue triangle mesh is shrunk/enlarged, not just the boundary. This parameter can be painted spatially. A value of 1.0 means no scaling, which is the default. To shrink the cloth or tissue, set zMaterial.restScale to a value less than 1.0, for example 0.8. To expand it, use values above 1.0. Rest scale can be animated over time using :ref:`sec-zCloth`.restScaleEnvelope or :ref:`sec-zTissue`.restScaleEnvelope. A value of 1.0 means that the scaling effect is fully applied, whereas 0.0 means that it is turned off. In-between values partially apply the effect. Negative values reverse the effect, and values greater than 1.0 exaggerate the effect. This feature can be used to grow or shrink parts of the character, and is generally used for animation or modeling purposes. For example, it can be used to easily make the ears of an elephant 2x larger, producing organic growth that is aware of collisions, gravity and other simulation parameters. A demonstration of cloth restScale and pressure is available in the :ref:`sec-demos` under "Cloth Rest Scale and Pressure." The difference between surface tension and rest scale is that the surface tension applies *only* on the surface of the object, whereas rest scale applies everywhere in the volume of the object. It is possible to paint the rest scale on the surface, and the values will be propagated into the interior. The rest scale will be applied using the propagated values everywhere inside the volume. This difference is very important for tissues. When simulating a creature's fat compressed against the muscles, we usually do not want to shrink the fat everywhere in its volume; instead, we only want shrinkage on the interior wall of the fat. This is where surface tension comes in handy: paint it to zero on the skin, and paint it to a positive value on the interior wall. .. figure:: images/surfaceTensionRestScale.png :alt: Comparison between rest scale and surface tension. Comparison between rest scale and surface tension. Rest scale applies everywhere inside the volume of the object, whereas surface tension shrinks the object's surface. Surface tension does not directly affect the interior of the object, other than indirectly via the elasticity of the object. Note that in the surface tension result, the central squares are almost undeformed. Animatable Inertial Frame ------------------------- The solver node can be transformed/animated using its translate, rotate and scale attributes. If the solver node and the bones of a creature are transformed in unison, the space that the tissues or cloth are being solved in will rigidly transform with the solver, canceling any inertial effects due to bone motion. This is useful for moving simulations away from the origin without incurring inertial effects. Isosurface Triangle Mesh Creation --------------------------------- It is possible to create well-conditioned triangle meshes using the Isosurface Triangle mesh generator. This is done by using a level-set-based approach and 3D Delaunay meshing. The input is an arbitrary Maya polygonal mesh that does not need to be closed, manifold or well-formed. It can have cracks, duplicate faces, T-vertices, etc. The output is a 3D triangle re-meshing of the same surface, or an offset surface. For the offset, both positive, zero and negative values are supported. The re-mesher can also remesh triangular meshes that do not enclose any volume (in which case the provided offset must be greater than zero). .. figure:: images/features3.png :alt: features3 image A long muscle meshed with the isomesher. All the angles in the output triangulation are greater than or equal to 30 degrees (unless manifoldness of the output surface is enforced, discussed below). The output of this node is a Maya mesh. As such, it is independent of the Ziva solver, and can be used for any purpose in Maya. The re-mesher does not assume that the input mesh is manifold or well-formed. It can work with arbitrary "polygon-soup meshes", including one-sided surfaces and surfaces with holes. The remesher can be used to fill holes in non-watertight geometry, and to create a good-looking surface matching the input geometry. In the context of the Ziva plugin, the remesher can be used to create a well-formed mesh to serve as an input to tissue creation. The output of this node also provides a good starting point for Delaunay Tetrahedralization. The parameters to the remesher are the level-set value to mesh (the "isoValue"), the target size of the output triangles, and the level-set resolution. The remesher parameters are: the level-set value to mesh (the "isoValue"), the target size of the output triangles, and the level-set resolution. * The isoValue is specified in scene units, and can be positive, zero, or negative. Zero and negative values only make sense when the input object represents a solid volume. In such cases, the zero isosurface will effectively remesh the input surface. A negative value will effectively "shrink" the object, whereas a positive value will enlarge it. If the input is not a closed volume, then the zero (or negative) isosurface will be empty. The parameters to the remesher are the level-set value to mesh (the "isoValue"), the target size of the output triangles, and the level-set resolution. * The triangle size is specified in dimensionless units, where 1.0 is a default triangle size. This parameter controls the size of the output triangles. For example, if you set it to 2.0, you can expect the output triangles to be approximately 2x larger than with 1.0. The larger the value, the coarser the mesh. Conversely, the smaller the value, the smaller the mesh, and the longer the running time. * The resolution controls the resolution of the internal level set representation. This controls what geometric features are visible to the method. Increasing the resolution will cause the output mesh to respect input detailed features more closely, at the cost of more memory and computation. In many cases, the output of the remesher is a manifold surface. When it is not, the produceManifoldMesh parameter, if enabled, applies a post-processing step that attempts to make the mesh manifold by removing hanging faces and performing edge collapses. You can disable this post-processing by turning produceManifoldMesh off. The Delaunay 3D tet mesher needs a manifold mesh as input. A demonstration of isomeshing is available in the :ref:`sec-demos` under "Isomesher." Thread Management ----------------- Our solver automatically uses threading to accelerate the computation. The amount of threading is controlled using the Maya multithreading settings (e.g. the threadCount command). The mesh and the problem must be sufficiently large (e.g., at least a few hundred tets) to see any advantage from multithreading.