Creating Grass with Splines

Login to Follow
  • Film & VFX
  • Scripting
  • Shaders
  • Maya
Skill Level
  • Intermediate

Tutorial by Lee Griggs Thanks to Pedro Fernando Gómez for his assistance with XGen.

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.

This video shows how to setup the scene.
Creating the Grass

?• Create a polygon plane with 20 subdivisions in both Height and Width. This will enable us to sculpt it into the plane to form a varied base for our grass. Scale the plane up to around 10 in X and Z.

?• Select the polygon plane and go to XGen>Create Description. This will open up the Create XGen Description below. ?• Choose the Splines (use for long hair, vines, etc). Leave the other default settings alone and click on Create.

?• It is good practice to lower the Percent value in the Preview/Output tab before continuing. If the Percent value is too high you may find that your computer will stall due to the large number of primitives generated.

?• Increase the Density to around 5000 in order to cover the plane with grass. Lower the Width to around 0.05 to make the grass appear thinner. Increase the spline Length to 2. Adjust the Taper to 0.5 and the Taper Start to 0.5 so that the splines look more like blades of grass.

?• Assign an Ai Standard shader to the XGen description. Change the Diffuse Color to green. Create an Ai Sky - Render Settings>Environment>Create Sky Shader and render the scene.

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 (see below) 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 in a random fashion:

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 ranges from 0.0 (the base of the spline) to 1.0 (the tip). ?• Click on the Expression icon (see below) next to Bend Param[0] and enter the following text in the XGen Expression Editor:

$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. ?• Create an Ai UserData Color node and connect it to the Color attribute of the Ai Standard shader assigned to the grass XGen description.

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

?• Type grassColor in the Color Attr Name of the Ai UserData Color node. We will use the same grassColor name in the XGen description.

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

?• Click on the Preview/Output tab in Xgen and open up Output Settings. Underneath you should see the Custom Shader Parameters. In the Name text field, type the same name that was used for the Color Attr Name with the Ai UserData Color node. In this case we used the word 'grassColor'. Click on float and change it to Color because this is the attribute that we want to change.

?• Click on the Expression icon (see below) next to the newly defined grassColor color attribute and enter the following expression:

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

?• Render the scene. You should see that the green Hue shading of the grass is now random.

Changing the Length with an Expression

Now we can also randomly change the length of the grass using an Expression. ?• Click on the Expression icon (see below) next to the Length attribute and enter the following expression:

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

The grass should look similar to this:

Finally, increase the Density to 10000 and you are ready for your finished render. Try adding some Backlighting and Specularity to the grass shader to get something that looks more realistic.

Example Render
Posted By
  • Maya
  • Scripting
  • Shaders
To post a comment please login or register
| 6 years ago
So, you can't complete this tutorial without buying Arnold for Maya? Oh well, the first image looks really good...
| 5 years ago
for me we are in 2015, the final texture in not good
Edited by j59FMA8t 5 years ago