This tutorial takes you through the process of creating the simplest vegetation asset; grass patches. It covers the basics of the vegetation shader parameters and introduces you to the Vegetation Tool in CRYENGINE. Grass patches is the former method that we used to make grass assets for the ENGINE. While this method is still valid and worth knowing our preferred and current method for creating grass is to use the Merged Mesh (MM) technology.
Pic1: Finished scene using grass patches.
The below example (Pic2) depicts the creation of grass patches using the vegetation tool. The one on the right is shown in a highlighted planes view.
Pic2: Grass objects in normal and highlighted planes view.
Source Maya scene with exported CRYENGINE files:
Before you continue with this tutorial, make sure to have read and understood the following topics:
Keep the following things in mind while working on your asset:
For this tutorial the asset has been created in the following directory:
<Your_Project>\Assets\
Objects\tutorial\vegetation\01\grass_patch\
Initially, we need to prepare the material that will be applied to the object. This enables us to give a visual reference to the texture that you are using when modeling or shaping the geometry planes for the grass patch. For the individual grass and the grass patches, you only require one material SubID for the visible portion of the mesh. Also, a physics proxy is not required on the object as the player is supposed to pass straight through the object without hindrance.
Under the Crytek shelf you installed, click the MAT.ED tab. In the Material Groups window, create a new Material Group and add a standard Phong shader to this Material Group. To create a new shader, open Maya's HyperShade to create a standard Phong shader. It does not matter if you choose a Phong, Blinn, or Lambert shader. You still need to set up the vegetation material in the Sandbox Material Editor later.
Pic3: Creating a new Material Group.
After you have added the new Material Group with one sub-material, you can open up the Maya and export an *.MTL material file using the CRYENGINE Exporter.
Pic4: Exporting the generated material files.
This will be saved into the same directory as the Maya source scene:
<Your_Project>\Assets\
Objects\tutorial\vegetation\01\grass_patch\
tutorial_grass_patch.mtlFor a grass patch, we define the object by a series of simple planes rotated in random directions and with variations in scale to achieve a dense look with minimal geometry. The idea is to make it look solid from every direction, i.e. in the X, Y and Z.
Make sure that the pivot of the object is roughly in the center and slightly up from the absolute bottom of the object. This slight vertical offset of the pivot allows the geometry to be slightly sunken into the floor which is useful in aligning to terrain function in the Vegetation tool. When used in this way, it will average out (as best it can) to fit with the variation in terrain height. This helps to avoid a gap underneath the grass patch and prevents it floating in space.
Make sure you do not set the pivot too high, otherwise you will lose the bottom of the geometry into the terrain.
Pic7: Pivot location, hit the Insert key to offset any pivots in Maya and keep X key pressed to snap to the grid.
This is an optional feature that can be applied to the asset. It is not required unless you use the asset with a specific material setup, such as Vertex Deformation. Without the vertex coloring in the asset, the simplified movement you get when using vertex deformation is applied across the entire geometry.
By default, the vertex color of the asset is white (full movement), but when you apply black to the base vertices (where the grass will be rooted to the floor), then only the tips of the grass will move (because they are colored white). This gives a much more realistic and believable looking asset.
Unlike the bending parameter that can be applied inside the vegetation tool and that automatically fixes the base of the grass to the floor. Vertex color is used to control the movement when you apply the movement via the vertex deformation within the material.
To modify any vertex color in your geometry, press F2 to go to the Maya's Modeling menu. Under Mesh Display -> Apply Color or Paint Vertex Color Tool, you add vertex colors. Instead of painting, it is easier to just select the bottom vertices and give them a black color which is interpreted as non-moving vertices in the vegetation tool settings later. Redo with white color for the top vertices. This will let them move freely.
Pic8: Applying the vertex colors.
When we progress to the CRYENGINE portion of this tutorial we will continue with the use cases for vertex color within the asset. For now, continue on to create the rest of the asset.
Even though this grass object is a very simple geometry with a total of 600+ polygons, it still makes sense to add LOD's to the object - so we can lose some of the extra polygons at distance.
If you are familiar with the 3ds Max to CRYENGINE workflow, you will notice that for the export from Maya, we must always:
When it comes to adding LODs it becomes even a bit more complicated. These are the rules:
This will result into an exportable hierarchy shown in the below image:
Pic9: LOD group nodes for the meshes.
To fill in the empty LOD group, use any means you have in Maya or external programs to reduce the different LOD mesh complexity. You can simply delete some grass patch faces or you could also use the Mesh -> Reduce tool to let Maya do the work. It's up to you. There is a guideline however, if you want to follow it:
Group the reduced LOD meshes under their respective group nodes, until you get this:
Pic10: Grouped LOD group nodes.
Since we already did the preparations of our export scene to include LOD groups, we only need to click the Export button to export the grass patch as *.CGF file. Click on the cryExportNode and go to the Attribute Editor if you need to re-evaluate the export settings shown below:
Pic11: Exporting the geometry and its settings.
We have now finished the setup for the Maya portion of the tutorial. To continue, move onto the next page where we configure the material and use the Vegetation Tool to place down some grass assets.