This tutorial shows you how to create a patch of grass very quickly and easily using XGen splines. We will also use some expressions to control the behavior and look of the grass.

The tutorial is broken up into the following chapters:

Creating the Grass
Bending the Grass
Randomly Changing the Grass Color with an Expression
Changing the Length with an Expression


A Maya scene can be downloaded here.


A video that shows how to setup this scene can be found here.

Creating the Grass

 

 

 

 

 

A plane with XGen grass splines (cube with a ramp has been placed under the plane).


Bending the Grass

Rather than bending the grass uniformly in one direction, we can use expressions to bend the grass in random directions. Bend U and V control how much the spline is bent at the corresponding CV. 0 is no bend, and 1.0 is a 90-degree bend.

Click on the Expression icon  next to Bend U[0] and Bend V[0] and enter the following text in the XGen Expression Editor:

$a=rand(-1.5,1.5);#-2.0,2.0
$a

 

The grass splines should appear bent randomly:

 

The grass is still looking a bit uniform. We can use the Bend Param[0] to add more variety. This attribute controls where along the spline the bending will occur. The values range from 0.0 (the base of the spline) to 1.0 (the tip).

$a=rand(0.2,0.9);#0.0,1.0
$a

The grass bend looks more random thanks to the Bend Param[0]

Randomly Changing the Grass Color with an Expression

We can use an expression with XGen along with the Ai UserData Color node to randomly change the hue of the grass.

Ai UserData Color node connected to Color attribute of Standard Surface shader

 

Add the name 'grassColor' to the Color Attr Name in the Ai UserData Color node

 

 

[rand(0,0.5)^0.5, 1,rand(0,0.3)]

 

 

 

 

Changing the Length with an Expression

Now we can also randomly change the length of the grass using an Expression.

$a=rand(0.5,1.0);#0.05,5.0
$a

 

 

 

The grass should look similar to this:

 

 

 

 

 

 


Thanks to Pedro Fernando Gómez for his assistance with XGen.