In this page we will learn to generate and edit softbody blueprints.
There are 2 different softbody blueprint flavors. Both blueprint types can be fed to ObiSoftbody actors.
To generate a basic softbody blueprint, go to Assets->Create->Obi->Softbody surface/volume blueprint, or right-click on a project folder and select Create->Obi->Softbody surface/volume blueprint.
Softbody simulation and rendering are taken care of by two separate components: ObiSoftbody (simulation) and ObiSoftbodySkinner(rendering). The former generates a particle-based representation of a mesh. The latter skins an arbitrary mesh to that particle-based representation, so that they move and deform together.
Using two separate components lets you decouple simulation and rendering, which is oftentimes very useful. Also please note that you're not forced to have a single ObiSoftbody skinner for each ObiSoftbody. You can skin multiple meshes to a single softbody, using multiple ObiSoftbodySkinners.
Softbody blueprints take a mesh as input. Any mesh will work, including non-manifold meshes and polygon soups.
When you press the Generate button in the blueprint inspector, particles will be generated using the mesh surface or volume (depending on the softbody type), then shape matching clusters will be generated. The cluster network is what holds the particles together, and simulates elasticity and plasticity. Let's take a look at all parameters that control particle and cluster generation:
The "Input mesh" slot in the softbody component allows us to specify which mesh to use for particle generation.
Radius of the particles that will be seeded on the surface of the Input Mesh. This is the main parameter that controls the quality/performance ratio of your softbody: a very small radius will result in many particles added to the mesh surface (as many as vertices in the Input Mesh). Larger values will result in coarser sampling of the mesh.
Percentage of overlap allowed between particles. Large values will ensure more thorough coverage of the input mesh surface, by means of generating more particles. Values of 0.5-0.7 usually are the coverage/performance sweet spot.
Amount of laplacian smoothing applied to the mesh prior to particle seeding. Large values can help in representing thin features such as antennaes and limbs with linear particle chains.
Radius around each particle that is considered when calculating the shape and orientation of that particle. Values close to or slightly larger than the Particle Radius give good results.
Maximum ratio between the longest axis of a particle and its shortest one. Large values will result in very pronounced ellipsoidal shapes, small values will result in more spherical particles.
Radius around each particle that is considered when linking that particle to the ones around it. Values 2-3 times the Particle Radius usually give good results.
If enabled, uses one-sided particles to help with collision detection. While regular particles project overlapping bodies in the direction of the shortest path to the particle's surface, one sided particles use the shortest path to the softbody mesh surface.
Generation is a process can take quite a while. Once it is done, the Edit button will activate. Pressing it you will enter the cloth blueprint editor.
There's three main modes in the cloth blueprint editor, that can be acessed using the 3 buttons at the top:
In particle selection mode, you can select particles to modify their properties, create particle groups, and generate tethers. To select particles, click and drag over them in the scene view. To deselect particles, hold the shift key while dragging.
You can change the brush size by dragging the brush size slider. You can change the particle culling mode to one of three options:
There's also a few available tools that operate on the current selection:
You can get/set any property of the currently selected particles:
You can group together particles that have a special role or significance to you. For instance, you could create a group out of the 4 particles at the corners of a rectangular cloth sheet, to be able to later hang it from another object. Groups are mainly used when creating particle attachments, but can also be acessed at runtime in custom scripts.
To create a new group from the current selection, simply press the "+" button at the bottom right corner of the list. To delete a group, select it from the list and click "-". You can also select all particles in the group by clicking the select button (multi-selection of groups using the shift key also works), and you can replace the particles with the current selection by clicking set.
All three blueprint editor modes (selection, painting and texture import/export) have a visualization options section. Here, you can change the render mode which determines the elements that should be drawn in the scene view. Some of the options are:
When the mesh render mode is active, the currently selected property (mass, radius, etc...) is mapped to a color gradient and used to draw the mesh. By default, the minimum and maximum property values are calculated and used to map values to a color gradient.
In property painting mode, you can use brush tools to paint particle properties directly on the surface of the cloth. Enabling the mesh render mode is recommended to work when painting.
The brush has a inner and an outer radius. The brush opacity within the inner radius can be set by changing the brush opacity value. The opacity smoothly decays outside the inner radius, reaching zero at the outer radius.
Most properties offer 3 brush modes:
If there are some particles currently selected, you can enable selection mask. When the selection mask is active, the paint brush will only act upon the selecte particles. This is useful if you only want to paint some parts of the mesh.
You can import/export any property to a texture using these tools.
When loading property values from a texture, we need know how to map pixel values to property values. Obi maps linearly from the 0-255 pixel value range to a user-defined property value range.
When exporting color properties, all 4 texture channels are used. When exporting floating point properties, the maximum property value in the mesh is mapped to white pixels (255) and the minimum value to black pixels (0). Values are always stored in the red texture channel.