This tutorial covers how to apply color to XGen splines using the User Data node in combination with a texture map. We will use a simple polygon mesh as the basis for our XGen description.
An example scene file can be downloaded here.
- Start off by creating a polygon mesh (such as a plane) that we will use to assign the XGen description.
- Select the polygon plane and go to Generate> 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 a large number of primitives generated.
- Increase the Density to around 30.
Spline Density set to 30
- Assign a standard_hair shader to the new XGen collection.
- Create an Ai UserData Color node and connect it to the base_color attribute of the standard_hair shader.
- Type color in the Color Attr Name of the Ai UserData Color node. We will use the same 'Color' name in the XGen description.
Add the name 'color' to the Color Attr Name in the Ai UserData Color node
- MtoA will not gamma correct the Ai UserData Color node. Therefore you will need to add a Maya Gamma Correct node in-between the Ai UserData Color node and the Tip Color attribute of the Standard Hair shader.
- Render the scene. The splines are black because the Ai UserData Color Default Value is black. We need to connect it to the XGen description using the Custom Shader Parameters in XGen.
Splines are using the black Default Color from 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. This is where we will add our expression.
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 'Color'. Click on float and change it to Color because this is the attribute that we want to change.
Custom Shader Parameters set to Color
- Click on the downward pointing arrow to the right of the color text field. Select Create Map... (it is important to note that this will only work if the plane has a Maya shader assigned to it). Increase the Map Resolution to around 200.
- You should see in the Hypershade and Node Editor windows that a file texture has been connected to the geometry. Select the file texture and open the texture map that you want to use to drive the color of the sphere primitives.
Remember to select the disk icon after updating the file texture. Otherwise, XGen will not bake the ptex map to disk and the render will not change.
- Render the scene. Your splines should now have the same color as your file texture map. You are done!
Thanks to Pedro Fernando Gómez for his assistance with XGen.