In this tutorial, we will be using our Detail Bending system and show you the process of how to setup vertex movement through vertex paint. We will use all three vertex color channels to control different movement behaviors for the leaf geometry of our bush asset. This effect is meant to be used on vegetation objects and will help us to create a performance friendly bending effect on our bush asset. It works best for vegetation with big leaves like palm trees and fern bushes.
Pic1: Final asset with underlying vertex color for this system to work
This system applies certain movement behaviors to vertices depending on the color you assign to them. You can change the intensity of those movement behaviors through shader parameters.
Source 3dsMax scene with exported CRYENGINE files:
Before you continue with this tutorial, make sure to have read and understood the following topics:
Make sure to keep the following things in mind while you work on your asset:
In this tutorial, we will be creating our asset in the following directory:
To being with, save your 3dsMax scene to this location. All our exported assets will be saved in there. Some of the textures that we use comes from an existing asset and the location of the existing asset will be provided later in the tutorial.
We will continue with the assumption that you have already created the asset, since this is not a 3dsMax modeling tutorial. We will begin with preparing the asset ready for CRYENGINE, assigning SubIds to the relevant polygons and configuring the material.
Pic2: 3dsMax overview of the finished model
First, we will configure the material for the object. In 3dsMax, open the Material Editor, and create a new material called tutorial_detail_bending.
Load in the diffuse map and normal map to the material paths. 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.
The example file refers to the following provided tutorial textures:
Pic3: Shader parameters setup
In the Shader Basic Parameters section:
See Pic2 above and note the material setup in the 3dsMax material editor.
Now we have configured the material for the object with its leaf properties.
Pic4: Selecting the correct material for the .mtl export
Our geometry for this tutorial is going to be a fern bush. This plant is perfect for explaining this type of technology. Create a single big leaf mesh for your fern bush and apply the material we just created to it (tutorial_detail_bending.mtl). Make sure that the geometry of your leaf is cleanly tessellated. Otherwise bending will break. Finally use the Unwrap UVW modifier to adjust its UV shell to fit around one of the leaves on the texture.
Pic5: Geometry of the leaf
Pic6: UV Layout of the leaf in 3dsMax. Note the leaf UVs matching the underlying texture
The next step involves painting the vertex color on our geometry. We use all three vertex colors to control different movement behaviors for the leaf geometry.
|Red||Creates irregular and small bending at the outsides. Black means no bending and a full 255/0/0 red means the highest amount of bending. The movement of smaller shapes itself goes back and forth on the X axis.|
|Blue||Creates slow and regular bending. Black means the highest amount of bending and a full 0/0/255 blue means no bending at all. The movement of the big shapes itself goes back and forth on the Z axis.|
|Green||Delays the start of the movement. Each green shade starts the bending at a different time to create bending variations.|
|Note the differences between the Red and the Blue channels. The black value (0,0,0) effects the influence in different ways.|
During painting of the leaf object its best if you show its vertex colors so that vertex color edits are visible. To see them, right click on your selected object and select the Object Properties.
Pic7: Leaf object properties selected
Activate the Vertex Channel Display check box under Display Properties within the General Tab . Make sure to have Vertex Color selected in the drop down menu. Click OK to confirm those changes.
Pic8: Leaf object properties, enabling vertex color preview
|If you keep your tutorial_detail_bending material assigned to your object, vertex color will multiply with your fern bush diffuse color. To avoid this, we recommend you to temporarily assign a white default material for a pure vertex color display.|
Pic9: Leaf showing vertex color with temporarily assigned default white material
Each color will be distributed through a separate Vertex Paint modifier. Even though there are no order in which the colors have to be painted, but make sure you use Red -> Blue -> Green.
To enable irregular micro bending:
Pic10: Vertex Paint modifier properties
Select the outer vertices on both the sides of the leaf and paint them with a full 255 red. Those vertices will get a maximum bending amplitude. Then select the vertices in between the border and the center and apply a darker red for a lower bending effect closer to the stem. This enables you to achieve a bending amplitude falloff from the outside to the inside of the leaf. In this case we will use a red with a value of 128 . Ensure that the middle line should always stay black. Small and irregular movement should only happen at the thinnest area of a leaf, its border. Close the Vertex Paint modifier.
Pic11: Red vertex color on leaf
In order to apply the upcoming blue and green colors, the geometry of your bush should have all of its leaves already in place. So start making copies of your leaf and place them around until you have a proper looking fern bush.
|You are free to temporally assign the tutorial_detail_bending material and deactivate the vertex color channel display mode while you create your bush.|
|You can also move UV shells to other leaves on your texture map as long as you do not change their geometry.|
|Creating and deleting individual vertices after a vertex paint increases the risk of information loss on those vertices.|
As soon as you are finished with the geometry layout of your fern bush, name it as tutorial_detail_bending.
Pic12: Full fern bush with proper material assigned, vertex color deactivated and with 2 leaf UV shell variations
Now that we have all of our leaves with smaller edge bending applied to them, now we can add big leaf movements on top of that.
Pic13: Bush with soft selected vertices in top view
Pic14: Blue vertex color on leaves
|To avoid overriding the red paint while collapsing the modifier, make sure to set its layer mode in the vertex paint dialog to add and then collapse the modifier.|
Pic15: Red color added to blue values
This time through the green channel we will add time delays to the leaves movement to break up the regularity and add variation.
Pic16: Shades of green added to our fern bush
Now go to the Layer section of your Vertex Paint modifier and again select add mode to combine the green vertex color with the other colors beneath. Your asset should now show all three vertex colors.
Pic17: All three vertex color channels visible
Reassign the tutorial_detail_bending material to your object.
We are now ready to export our geometry to the engine. In the CRYENGINE exporter:
Pic18: Adding the asset to the exporter with the correct export flags checked
We have now finished the setup for the 3dsMax portion of the tutorial. To continue move to the next page where we configure the material and use the Vegetation Tool to place down some of these detail bending assets.