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 Editor in CRYENGINE. Grass patches is the former method that we used to create grass assets for the ENGINE. Even though this method is still valid and worth knowing, our preferred 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 Editor. The one on the right is shown in a highlighted planes view.
Pic2: Grass objects in normal and highlighted planes view.
Source 3dsMax 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 assets:
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 provide 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.
You can add a proxy to the object, but it is not recommended for grass patches.
Pic3: Material setup in 3dsMax, left is the top level of the multi-material, on the right the SubID's properties.
Default settings for the SubID's properties in the Material Editor
In order for the Diffuse and the Specular colors to align with the PBS model they are set as follows:
Specular between the 40,40,40 -> 60,60,60 range
The example file refers to the following texture that is already provided within the build. Link to this in the Diffuse Color map:
<Your_Project>\Assets\
Objects\natural\ground\grass\textures\grass_mix_diff.tif>
We are not adding a normalmap (ddna). This is intentional, since we want our grass asset to be as cheap as possible and we achieve this by enabling the grass flag in the Shader Params section. The grass flag runs the shader through a cheaper pipeline and the main benefit of this is that it does not need a normalmap.
Even though you will be able to add one, but it won't be used. Hence, it's a waste if grass is ticked in the Shader Generation params.
Now we have configured the material for the object with one SubID.
Pic4: Selecting the top level of the material (not a SubID) to export.
Ensure you follow the following prerequisites:
<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, such as in the X, Y and Z direction.
Steps for setting up an object:
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 according to the terrain function in the Vegetation Editor. 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.
Pic10: Pivot location slightly higher than the base of the object.
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 (since 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 Editor and it 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.
Inside 3dsMax, configure the asset to display the vertex colors. Right click on the model and select Object Properties. Enable the checkbox to display vertex channel display and ensure that vertex color is selected from the drop down list.
Pic11: Enabling vertex color display on the asset.
With the asset selected, add a vertex paint modifier to the stack.
Pic12: Apply the vertex colors, black = no movement, white = maximum movement.
Process for applying 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.
To add LOD's make sure the following rules are set:
Pic13: Overview of the LOD chain.
In this example, we are using two LOD's for this asset. The naming convention and polygon count are as follows.
Name | LOD | Description | Polygon Count |
---|---|---|---|
tutorial_grass_patch | LOD0 | Main mesh you'll see up close | 652 |
$LOD1_tutorial_grass_patch | LOD1 | First LOD | 412 |
$LOD2_tutorial_grass_patch | LOD2 | Second LOD | 212 |
Note, there is an approximate 50% drop in polygons as we step down the LOD chain. It is not a hard rule to follow, but we recommend you to aim for that level of optimization when switching LOD's. It is of course down to a per-asset basis as to how many polygons you can safely remove without destroying the look of the asset.
When you link the LOD's to the parent object (dummy helper or in this instance the main mesh) all the LOD's must connect directly to the parent.
Pic14: Schematic view of the hierarchy that all LOD's are siblings of each other and linked to the parent.
We are now ready to export our geometry to the Engine.
In 3dsMax go to the 6th tab (Utilities) and in the CRYENGINE exporter:
Pic15: Exporting the asset.
Pic16: Successful export log.
We have now finished the setup for the 3dsMax portion of the tutorial. To continue, move onto the next page where we configure the material and use the Vegetation Editor to place down some grass assets.