Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Section
Column
width50%

 In this tutorial, you will learn how to create a simple scene with XGen primitives to produce a grassy surface.

UI Text Box
typenote

Before proceeding with this tutorial, it is advisable to read the XGen General page first.

Want to follow along but don’t have a license?


UI Button
colorblue
newWindowtrue
icondownload
titleDownload Free Trial
urlhttps://www.chaos.com/free-trial?utm_campaign=docs-tutorials&utm_medium=website&utm_source=docs.chaos.com


Column
width5%

 


Column
width45%

 

 


Part I: Creating a Grass in a Simple Scene

...

These steps will guide you through creating a simple grass surface. 


Section
Column
width55%

Set Up the Splines

Here we will show you how to instance splines to create grass in your scene.

First create a plane and with XGen, assign a description with splines randomly across the surface.

Note: There is no problem using groomable splines, but we will use normal splines to show you how to control their attributes with expressions/maps procedurally.

 
Column
width5%


Column
width40%

 

 


...


From the Preview/Output tab, set the Percent attribute to 10 (this will affect only the viewport).

...

Create a V-Ray Dome Light in the scene and render. Your rendering should look similar to the image below.

 


...



Part II: Randomizing Hair Strand Color

...

There are two parameters that control the color of each strand: root_color and tip_color. If different colors are assigned to both, the color of each hair strand will be interpolated upwards from the root color to the tip color. If only one color is assigned to both, the whole strand will be colored evenly with that color.

 


Section
Column
width55%

Colorize the Roots

Here are the steps to colorize splines:

Assign a V-Ray Hair Sampler to the Diffuse Color of the material.

Go to the Preview/Output tab of the XGen window and scroll down to the Custom Shader Parameters section. Add root_color as type color as shown.

Column
width5%

 


Column
width40%

 

 


...


Section
Column
width55%

You should then see your parameter added above the textbox, and now an expression can be assigned to it.

Use this expression for the custom shader parameter:

Code Block
languagephp
[rand(0.3,0.7), rand(0.3,1),rand(0.3,0.7)]

Render the scene.

Column
width5%

 


Column
width40%

 

 

...


...



...

 


...


Section
Column
width55%

Colorize the Tips

We can also use the tip_color together with the root_color.

A texture map could be also used, as described on the XGen General page.

Using this setup and an image of painted easter eggs, we get the following render as a result. Notice how the root part of the strands remains green.

Column
width5%

 


Column
width40%

 

...


...


...


...

Section
Column
width55%
If you don't want to be restricted to just two colors along the strand, you can use a ramp texture. This time instead of directly connecting the V-Ray Hair Sampler, assign a ramp texture to the Diffuse color of the material. Connect the distanceAlongStrand of the V-Ray Hair Sampler to the vCoord of the ramp texture. Your shading network should look like this:
Column
width5%

 


Column
width40%

 

 


...


Section
Column
width55%
Or you can combine both methods. First you paint your root and/or tip color as in earlier steps. But instead of connecting the V-Ray Hair Sampler directly to the material, use a ramp texture with and attach the V-Ray Hair Sampler as a color at the positions you want to sample the textures. Your shading network should look like this:
Column
width5%

 


Column
width40%

 


Tessellation Parameters

...

Section
Column
width55%

V-Ray has options for the tessellation of XGen splines.

Go to the Preview/Output tab, and from the Output Settings choose V-Ray as the the Renderer. Find the V-Ray Settings in the Preview/Output tab.

The Hair Tessellation Mode and the slider below it can be used to tweak the tessellation and thus rendering speed, memory footprint and quality.

Column
width5%

 


Column
width40%

 

 

 

 





Limitations and Problems

...

When working with groomable splines, if a render or a IPR render happens, to continue updating the splines with respect to the groom splines, one has to refresh XGen, groom a bit more and refresh again. Only then will the splines regenerate accordingly to the groom splines (which are only for the viewport).