This procedure is for big leaves or branches, which bend on collision. It is a type of bone / rope setup based on UV instancing but newer versions of the engine actually feature a easier to use, more optimized approach known as merged mesh deform. Both techniques should be considered before applying. More information on merged mesh deform can be found at the bottom of the page
Touch bending is a simple rope setup to simulate a physical interaction between the player and vegetation foliage. This method works well for big leaves, with separate stems/branches, as well as bushes.
General Setup Information
Touch bending uses some clever techniques to simplify the setup procedure massively:
- Instancing for the setup works via shared UV's: leaves which share the same UV space will automatically work with touch bending.
- Joints are setup via helpers/dummies, which are connected via naming convention.
- A volume proxy needs to include all branches being used for touch bending.
Setup of Instances (UV Layout)
- By sharing the same UV space, objects can inherit the joint setup from a "master leaf".
- Below you can find the UV Layout of a typical setup for a palm tree. The red outline indicates the UV for the upper side of the palm tree leaf.
- Instances can be created by duplicating the "master leaf" an element or cluster within the same object. Rotation, translation, Scale and even changes to the shape of the instance can be applied to instances (moving individual vertices, not changing vertex count).
The joint setup is controlled by placing helpers/dummies at sensible positions on a "master leaf" and by following a naming convention.
Place the dummies where you would like the branch to start bending, one or more intermediate steps and at the tip of the branch.
The dummy position must be equal to the vertex's position, which they are supposed to animated. The best way to achieve this, is to snap the dummy to the vertex.
The engine interpolates between these dummies with a kind of rope setup and weights all other vertices automatically. Please check the picture below for the null positions.
The system allows for numerous branches (this is how the rope based joints are called) per object. The naming convention is relatively simple:
branch<# of branch>_<# number of joint>
This dummy setup only has to be done once per shared UV Layout.
In the example above it is branch1_1, branch1_2 and branch1_3.
If you want to add another branch with a different UV Layout, just name the dummies for this branch: branch2_1, branch2_2, ..., branch2_4.
- Your object need a proxy for this which is physicalized as "noCollide".
- Touch bending will only be detected in this volume.
- In the picture below, the orange circle indicates the size of this proxy. Ideally, the proxy is big enough to enclose all branches, being setup for touch bending.
3ds Max Setup
You can find a sample file in the Sample Assets Package.
This procedure is for big leaves or branches, which bend on collision. Its a kind of bone or rope setup based on UV instancing.
Your object need a proxy for this which is physicalized as "noCollide". Touch bending will only be detected inside this volume.
You can create the setup for one branch/leaf and it will be the same on all other branches/leaves which share the same UV mapping.
In the first example we have an object using the trunk as position and rotation parent. That means you can't attach a branch to another branch because it would take the trunk as rotation reference.
You need to place dummy objects using vertex snap so that they are exactly on the vertex.
Use the following names for the dummies:
If you want to make a second branch with a different mapping setup, name the dummies like this:
You can add more branches if you need to. Be sure to number them correctly. Set the pivot of your object to worldspace 0. At the moment we have a maximum limit of 32 ropes / bones in the engine.
Using Parents and Childs for bending:
To make a branch dependent on another branch, you have to give your parent another unique UV mapping (should not share the mapping with the childs). In addition your child "branch* _1" dummies (your start dummies) have to be within the bone's radius of your parent branch.
Keep in mind that the bones/ropes will be generated in-game always between two dummies which you placed in 3ds Max before. So you can place the start dummy for your child bone somewhere on the line between two linked branch dummies from your parent branch.
The engine will automatically detect those intersecting bones and creates a parent child setup. The parent branch dummies don't have to start with branch1_*. They could also use branch2_*. It just depends on, if your branch start dummy is intersecting with another "branch line" (two linked branch dummies).
You can use p_draw_helpers 2 in the console command line to debug touch bending in the editor. There is no way for artist to tweak the bending itself. Contact a Programmer for this.
Export your objects like this:
1. Create a group under the 'cryexportnode' named '@_helper' replacing the '@' with the name of your model.
2. Create a material for the trunks which uses 'default' physicalisation to physicalise the render geometry.
3. Create a material for the leaves which has 'none' set for its physicalisation option.
4. Assign the relevant materials to the trunks and leaves.
5. To create a bendable branch you must place locators that are snapped to vertices along the leaf. The locators must use the naming convention branch%_$ - where % corresponds to the branch id and $ is the joint id on that branch eg. branch1_1, branch1_2 and branch1_3.
6. To enable the branches to become usable in game you must add a 'bending_proxy' volume that encompasses the extents of the leaves that will be bendable. eg. create a sphere and ensure the branches are on the inside of the sphere.
7. Create a new material for the bending proxy with 'NoCollide' set as its physicalisation.
8. Apply the bending proxy material to the bending_proxy geometry.
9. Select the 'cryexportnode' group.
10. Select the file type from the drop down that appears in the 'Node Options' section.
11. Ensure the 'Do Not Merge Nodes' option in the 'Node Options' section is checked.
12. Click the 'Export' button on the 'Crytek Export' dialog.
13. The hierarchy with lods and proxies and branches should look like the above.
Place your object as vegetation. The material needs to be Vegetation Shader with the leaves checkbox turned on.
Merged Mesh Deform
This is a new option for deformable, interactive vegetation, setup is similar to previous techniques but much easier to use. Please visit Cloth Merged Mesh Deform for more information.
The following console variables can be used to tweak the physical behavior of the branches (some of them can also be set on a per-asset basis via UDP keywords, listed in brackets - for instance "damping 10.5")
- e_FoliageBranchesStiffness (stiffness) - how fast the branches will try to return to the original pose
- e_FoliageBranchesDamping (damping) - used to damp the stiffness; without it a branch would sway back and forth, never coming to rest
- e_FoliageBranchesTimeout (timeout) - if a vegetation object doesn't have any collisions within this time interval, it gets forcefully deactivated (even if it still moves)
- e_FoliageBrokenBranchesDamping - same as damping, but for parts of vegetation that breaks away
- thickness (UDP-only; if not set, either 0.03 or 0.1 is used, depending on length) - sets ropes' thickness