In this tutorial, we will show you the process of how to set up physical interactions between the hanging leaves of a willow tree asset and any other physicalized object in the level (such as the player). To achieve this, we will be using our Merged Mesh Deform system in CRYENGINE.
Merged Mesh Deform Cloth is an improved and optimized system over the cloth entity. Through this system, it is possible to set up assets with cloth behavior as brushes and vegetation objects. In contrast to normal cloth entities in CRYENGINE, the Merged Mesh Deform Cloth has static geometry and deformable cloth geometry stored within them at the same time.
This method works great for hanging vegetation like swamp moss or willow tree leaves. But we can also imagine other purposes, like poles (static) with flags (deformable) or laundry (deformable) hanging between two poles (static).
Pic1: Merged Mesh Deform in action with a non-zero wind vector
Source Maya scene with exported CRYENGINE files:
Before we continue with this tutorial, make sure to have read and understood the following:
Pic3: Screen capture of the start and finished Maya scene
Pic3: Overview of the finished exportable hierarchy
For this tutorial, we will create our asset in the following project directory.
<YOUR_PROJECT_FOLDER>\Assets\Objects\tutorial\vegetation\06\tree\merged_mesh_deform\maya\
(As an option, you may also start with the opening of the provided tutorial Maya scene: merged_mesh_deform_start.ma)
Save your Maya scene to this location if you haven't. All our exported CRYENGINE assets will be saved in there. Some of the textures we are using are in the former CRYENGINE GameSDK project textures folders. We will point you to the directory later in the tutorial.
We assume that you have already experience in creating/modeling simple poly geometries, since this isn't a Maya modeling tutorial. You can use the provided tree asset from this tutorial or use your own.
We will begin with the preparation of the assets which needs to be compatible with CRYENGINE. First step is to prepare the materials and set the User Defined Properties (UDP). We need to create an empty Material Group and add three sub-materials/shaders to it, one for the leaves (ID 01), one the tree trunk (ID 02) and the last one for the trunk collision proxy (ID 03). The order to add these three shaders are not important.
As in the previous vegetation tutorials, we must create an empty Material Group with the shelf button MAT.ED from the installed crytek shelf:
The material creation process in Maya for CRYENGINE always requires you to add the Physicalize extra attribute to the shaders. In Crytek shelf open the Export Tool, with your shaders selected, please click on the Add Attribute button.
Remember that you won't get any feedback by the Add Attribute button. You have to check the Extra Attribute section of the Maya shader/material with the Maya's Attribute Editor.
Repeat the above step for the other three sub-materials/shaders.
Pic5: "Add Attribute" to add Physicalize extra attribute to the shaders
Next we will set the Physicalize attribute of the three sub-materials/shaders and assign the texture maps to their diffuse and bump/normal map slots.
Select the leaves sub-material/shader (ID 01).
The example file refers to the following provided tutorial textures:
Add the diffuse texture file to the diffuse color slot and the *.ddna normal map to the bump map slot of the leaves_SUB Phong shader. The diffuse map should contain an alpha map for the opacity. The normal map should also contain an alpha map for the PBS smoothness value.
Select the trunk_SUB sub-material/shader (ID 02).
The example file refers to the following provided tutorial textures:
<YOUR_PROJECT_FOLDER>\Assets\Objects\tutorial\vegetation\06\tree\merged_mesh_deform\maya\tutorial_merged_mesh_deform_trunk_diff.tif>
<YOUR_PROJECT_FOLDER>\Assets\Objects\tutorial\vegetation\06\tree\merged_mesh_deform\maya\tutorial_merged_mesh_deform_trunk_ddna.tif>
Add the diffuse texture file to the diffuse color slot and the *.ddna normal map to the bump map slot of the trunk_SUB Phong shader. The diffuse map should contain an alpha map for the opacity. The normal map should also contain an alpha map for the PBS smoothness value.
Select the proxy_SUB sub-material/shader (ID 03).
Set the transparency color to a light red, so you can spot your proxy object on top of the actual geometry better.
As the material setup is independent of the rest of the scene, we can already export the current work-in-progress material to CRYENGINE. We will finish this set up in the next tutorial section. But for now:
<
Your_Project>\Assets\
Objects\tutorial\vegetation\06\tree\merged_mesh_deform\maya\tutorial_merged_mesh_deform_MAT.mtl
Pic9: material export from Maya
To remind you of the important aspects of creating merged mesh deform vegetation for CRYENGINE:
Key to merged mesh deform exported from Maya are these elements:
Our geometry for this tutorial is going to be a willow tree. With its hanging leaves this type of tree is perfect for showcasing cloth-like physics on an otherwise static object. For this feature to work, we have to model these geometries:
And place the upper three geometry types into a correctly set export hierarchy.
Now let's advance to tweak these geometries.
We start with the tree trunk polymesh. But instead of going into details, we assume you to use either the provided Maya scene and skip to the end of this modeling process. If you created a tree trunk yourself, please add a clean UV layout for it. Use any UV editing tools Maya internal or external programs.
Pic10: Geometry of the trunk and its proxy already set into the export hierarchy.
Now let's concentrate on the creation of the leaves.
Pic11: Geometry of all three tree leaf patches under the bendalbe00_group
Pic12: UV layout of the leaves in Maya's UV Editor.
The leaf UVs in the above image should match the underlying texture.
Before we continue creating the rest of the tree by duplicating and distributing the leaves, we will add vertex color to them.
As stated before, you may use a black to white gradient to mark the intensity of the cloth physics effect (black 0%, white 100% intensity). But we use just the green channel and leave the red and blue for other vegetation deformation effect which you may have learned from the previous vegetation tutorials.
In Maya, press F-2 to switch to the Modeling menu, and then go to Mesh Display->Apply Color or Mesh Display->Paint Vertex Color Tool.
With the leaf geometries selected, go to the Paint Tool, and flood the Vertex Color channel of the mesh vertices with 100% green. Now set the color to black and paint the vertices, which should stay connected to the branches of the willow tree. See the below image for results.
Press and hold B key with mouse dragging to the left or right to increase the brush size.
Remember: Maya's Paint Tool only activates if you have paintable geometry selected.
Pic13: Adding vertex color to the leaves
You cannot export multiple UV, since this is not supported by CRYENGINE. You may come into this situation, after you imported a vertex painted mesh from FBX or applied vertex colors. You have to collapse multiple UV sets into the Maya default map1 UV set.
Beware: Handling of multiple UV sets in Maya's UV Editor is never easy. Save the project before you continue. You can also use Maya's UV Set Editor in the Maya's Modeling menu: UV->UV Set Editor to get rid of non-default UV sets after copying them to the default UV set map1.
map1 UV sets cannot be deleted since it is the default UV set for the object.
Pic14: Verifying the multiple UV sets.
Pic14a: UV Set Editor
Now let us collapse (copy and paste) the UV sets back into one. The goal is to select and copy the UVs for each UV set and paste them into the default map1.
After that purge/delete all the empty UV sets with UV Set Editor.
In order to activate the merged mesh deform system, we are still missing the UDP setup part. In Maya, you can set this by adding UDP to the Extra Attribute section by using the UDP shelf button from the Crytek shelf.
Pic18: UDP window for activating mergedmesh_deform
As shown in Pic18 above, you must at least type mergedmesh_deform into the UDP window and then click the Save button.
These are the available parameters used to define merged mesh deformable geometries:
UDP | Description |
---|---|
mergedmesh_deform | Required to enable mergedmesh deform cloth physics for this node. |
mergedmesh_deform_stiffness | Defines how stiff the deformable is, between 0.0 and 1.0. |
mergedmesh_deform_damping | Controls how quickly the deformable will settle, between 0.0 and infinity. |
mergedmesh_deform_variance | Controls how much randomness is in the wind sampling algorithm, between 0.0 and infinity. |
mergedmesh_deform_air_resistance | Scales the wind influence, multiplied with the levels wind force. |
mergedmesh_deform_air_frequency | Cosines modulated speed of wind per vertex, between 0.0 and infinity. |
mergedmesh_deform_air_modulation | Cosines modulated speed of wind per wind-force, between 0.0 and infinity. |
mergedmesh_deform_max_iter | Amount of simulation iterations, between 1 and 12, 3 is default, the higher the more expensive. |
Repeat the UDP setup for all bendable##group nodes after you duplicated the leaf geometries and parent them under a bendable group node.
The leaves need to be scattered around the tree trunk branches. You may combine the geometries (Don't forget to Delete History) or you can just parent these under the bendable group. This was demonstrated for the bendable00_group. The other bendable group nodes are combined mesh pieces. But don't go overboard with using bendables group nodes. Maximum of ten should suffice and you will not get a performance drop by SPU bottleneck.
Pic19: Merged leaf patches together with trunk
Now it is time to reorganize all the mesh node and transform/group nodes under a cryExportNode. See the lower pictures for reference, and open the provided final Maya scene and examine the hierarchy there: merged_mesh_deform_finish.ma
Pic20: Final exportable hierarchy
We are now ready to export our geometry to the engine. On Crytek shelf, click the Export button to open Maya to CRYENGINE exporter:
Pic21: Ready to export the geometry files.
We have finished the setup for the Maya portion of the tutorial. To continue move to the next page where we configure the material and use the Vegetation Editor to paint some of these merged mesh deform assets.