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 Grass objects in normal and highlighted planes view.
|Table of Contents|
Before you continue with this tutorial, make sure to have read and understood the following topics:
- How to install CryMaxTools
- The basic CRYENGINE 3dsMax workflow
- CRYENGINE Exporter
- 3dsMax unit scale to match up with CRYENGINE unit system
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
- Diffuse = 255,255,255
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:
Now we have configured the material for the object with one SubID.
Pic4: Selecting Selecting the top level of the material (not a SubID) to export.
Ensure you follow the following prerequisites:
- Create a polygon plane and apply the material tutorial_grass_patch to it.
- Make sure that the SubID is set to ID 1.
- Name the polygon object tutorial_grass_patch.
- Use the Unwrap UVW modifier to adjust your UV shell to only fit around one of the grass patches on the texture.
Pic5: Arrange the UVs of the polygons to fit one of the grass textures.
- Using this setup, duplicate the polygons and distribute them around the area which you would like the patch to cover. Apply random rotation and scale to the patch to break up the uniformity of the object (Make sure you do not over modify which may start to stretch the textures).
- Try to end up with a rough hexagon shape for the entire patch. This works the best in most situations.
Pic: 6, 7, 8, 9: Example grass patch geometry build up.
- After you have finished the geometry distribution attach all the individual planes together into a single base object (tutorial_grass_patch).
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.
Apply Vertex Color (to control material Vertex Deformation)
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.
|To help visualize where you are assigning colors to, apply a different standard material (a spare empty material with the flat grey color) to better see colors on the vertices. However, do not forget to return it to the correct material after you have finished the vertex painting.|
Pic12: Apply the vertex colors, black = no movement, white = maximum movement.
Process for applying vertex colors:
- Use the $LOD prefix to the LOD's name (e.g. $LOD1, $LOD2 etc...). The naming convention of $LODxxx to inform the Engine that this is an LOD.
- Try to reduce the polygon count by approximately 50% per LOD step (if possible) while still preserving the overall shape.
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.
|tutorial_grass_patch||LOD0||Main mesh you'll see up close||652|
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.
Export the Geometry
We are now ready to export our geometry to the Engine.
- Add the root node of the geometry asset to the export list (in this case it is called "tutorial_grass_patch").
- Select 'Geometry (*.cgf)' from the Export format drop down list.
- Press the Export Nodes button.
Pic15: Exporting the asset.
Pic16: Successful export log.
Continue to CRYENGINE
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.