Tetra Setup

This tutorial outlines the recommended workflow for setting up and using tetrahedrons in the Carbon Tetra node. Additionally, it incorporates advanced techniques such as applying paint maps and using Carbon Joint nodes. It is recommended to first study the Avatar Cloth, the Tetrahedralization and the Painted Attribute Maps in that order, as they cover all necessary know-how needed to easily comprehend this tutorial. Furthermore, please refer to the Carbon Tetra reference for details about all tetrahedron specific parameters and Carbon Joint for general information about the available joints in Carbon.

The remainder of this tutorial teaches how to create a mattress object from tetrahedrons, place it on a ramp-shaped Carbon Collider, paint the mattress non-uniformly and then drop a spherical Carbon Rigid Body on it to show the different behaviors induced by the paint map.

Creating The Mattress Geometry

First, create a box that matches the desired mattress shape. Next, in preparation for a Remesh, add all current edges to a edges group.


Creating a group for all hard edges.

Then, apply a Remesh node and set the Hard Edges Group. This is important to preserve the sharp edges.


Remeshing the box while maintaining all hard edges.

Finally, tetrahedralize the geometry with the Tetrahedralize node.


Final tetra geometry.

Make sure that the One Surface Face per Tetrahedron checkbox is ticked. Simulating tetrahedral geometry is the most stable when each individual tetrahedron only has one surface face.

Additionally, Max Radius-Edge Ratio and Min Dihedral Angle are adapted. Max Radius-Edge Ratio should be as small as possible, while Min Dihedral Angle should be as large as possible.

See also

Please refer to Tetrahedralization for more information.

Painting The Mattress

In order to achieve different behaviors within the same geometry, one needs to paint certain attributes. Paint the following parameters as these influence the squash and stretch of Carbon Tetra nodes:

The most efficient way is to create one of the attributes in a Carbon Attribute Copy node, for example Stretch Stiffness. Then, paint that attribute and add another Carbon Attribute Copy node to copy the values to all other attributes.

Using A Script For The Gradient

The mattress is to be painted with a gradient, where a larger part should be all red, while only a small area on the left hand side should remain white. Painting an exact gradient by hand using the Paint node can be tedious. In many situations, it is much easier to use a script to set attribute values.

First, insert the Carbon Attribute Copy node, which creates the Stretch Stiffness point attribute and initializes it to 0. Next, add a Point node, switch to the Custom tab and apply a script for the attribute stretchStiffness. This is where it comes in very handy that the mattress geometry ranges from exactly 0 to 1 in z direction, as all painted attributes also range from 0 to 1. A simple exponential function then provides a mapping between z coordinate and stretchStiffness value for each point.


Using a script for the attribute gradient.

Finally, append a second Carbon Attribute Copy node and copy the values from stretchStiffness to all other attributes mentioned above.


Copying stretchStiffness to all other necessary attributes.

Arranging The Mattress and Adding Props

Next, rotate the mattress geometry about the x-axis, add a ramp and a sphere geometry. This concludes the setup at geometry level.


Setup at object level.

Setting Up The DOP Network

The DOP network contains four object nodes:

Additionally, there is a Carbon Joint and a Carbon Simulation node.

The Ramp and Sphere parameters are shown below.


Ramp and Sphere parameters.

The Carbon Actor and Carbon Joint are necessary to prevent the rolling Sphere from falling off the Mattress. For such a situation, use the Prismatic joint. Applying a prismatic box with a size 0 in x direction forces the Sphere to stay on a straight path. The actor will assume the role of anchor to the world.


Actor and Joint.

The simulation is set up with almost all default values. Iterations is increased to 30 to ensure a smoothly operating squash and stretch behavior. And Damping is set to 2 to ensure that the Sphere does not roll off the Mattress too fast.

Below is shown the complete DOP network. The next section explains in detail how to set up the Mattress, i.e. the Carbon Tetra node.


Setup at DOP network level.

Setting Up The Carbon Tetra Node

The mattress has been painted so that the top is unaffected and the bottom part is affected by the paint map. The target is to turn the mattress very stiff and undeformable at the top and have it very soft and deformable at the bottom. The screenshots below show how to set up the main parameters for the Carbon Tetra node. Please refer to the hip file at the bottom of this page for all other parameters.


Self-Collide and Fatness parameters.

For scenarios like this, Self-Collide can be toggled off as there is no twisting or folding of the mattress.


Disabling the self-collision check increases the simulation speed and should be disabled whenever possible.

The usage of an outer fatness is not required but it increases stability, collision detection accuracy and also reduces penetration singularities. Moreover, it may be used to create a virtual cage/buffer which can later be filled with a high-resolution model for rendering. If a small outer fatness is wanted, keep in mind that values lower than about two magnitudes smaller than the edge lengths of the mesh do not produce any visible difference. That means that for this scenario, 0.0002, i.e. 0.2mm, suffices as smallest outer fatness as the individual tetrahedrons have edge lengths in the magnitude of 2cm.

Inner Fatness is the most complicated parameter of the Carbon Tetra node. It describes the penetration depth limit at which it becomes impossible to tell which face provides the correct separation direction for collision detection and resolution. Therefore, the value is very much dependent on the tetrahedron simulation. If a Carbon Tetra node is subject to heavy deformations, a large Inner Fatness could mean that objects get pulled through another part of the collision surface as they enter the large Inner Fatness cone of a face, i.e. the simulation will literally blow up. On the other hand, using a larger Inner Fatness increases determinism of the collision detection and overall stability.

The following guidelines help find a suitable Inner Fatness value:

  • Always use an Inner Fatness less than half of the width of the smallest part of the geometry, e.g. for a box, half of the smallest edge length.
  • Small deformations: A generous Inner Fatness, as mentioned in the previous point, can be applied.
  • Large deformations: The Inner Fatness should be smaller than the size of the smallest tetrahedron.
  • Heavy deformations: The Inner Fatness should be set to 0, while relying on double sided collision with a generous outer fatness to prevent objects from going through one another.

In case of this tutorial, the mattress undergoes very large deformations at the bottom and a small value for Inner Fatness has to be applied. 0.002 works very well in this example.


If the Inner Fatness is set to 0, the collision surface is then considered double sided, where, once crossed, the new collision surface is defined by the back faces.

More information on how to set up fatness values can be found in Fatness.


Setting the Density, Compression and Extension parameters (Base values on the left and Range on the right).

Setting the Base values for Volume Compression and Volume Extension to 1 indicates that the volume of each tetrahedron is preserved where a painted Range of 0 is applied. Together with Base values of 1 for Stretch Compression and Stretch Extension, squash and stretch is prevented at the top of the mattress. The Range values for compression add rather extreme offsets, ensuring that no tetrahedron is constrained by hard limits at the bottom of the mattress.

For more information about extension and compression, please refer to Compression/Extension.


Final simulation.