Create seExpr expressions for materials and shaders

You can create seexpr shader expressions to modify the materials and shaders that are assigned to your Descriptions. For example, you can create a shading network with any material, and then use an seExpr shading expression to pass color information from the shader to the primitives in your hair groom.

To do this, you must create an xgen_seexpr node so that your expressions can access the shading parameters in your material. This node can read Ptex maps and evaluate the expressions in your Description. The xgen_seexpr node then passes the results of this data to the material at render time.

If you are new to using XGen expressions, see XGen expression basics.

This example describes how to use an seExpr expression to modify a shader by adding noise to its specularity channel.

Create a custom shader parameter

  1. In the XGen Editor, click the Preview/Output tab.
  2. In the Preview/Output tab, go to the Custom Shader Parameters section.
  3. Beside Name, type SpecNoise.
  4. Ensure that Float is selected as the parameter type and click .

    Maya creates a new float type shading parameter called SpecNoise.

    Next, you create a noise expression to control Specular Color.

Create a noise expression

  1. Click this icon beside the shading parameter to open the XGen Expression Editor.
  2. In the XGen Expression Editor, do one of the following:
    • To use a sample fbm noise expression, click the Samples tab and browse to Global > Color > Procedural > Noise > fbm.
    • To create a simple noise expressions, type rand(0.3, 1.3)*noise(0,1).
  3. Click Accept.

    Next, you create the xgen_seexpr node that evaluates the expression.

Create an xgen_seexpr node

  1. Open the Hypershade (Windows > Rendering Editors) and select the shader assigned to your Description.
  2. In the Node Editor ( Window > Node Editor), display the shader node connections.

    For information about displaying node connections, creating nodes, and connecting nodes, see Node Editor basics.

  3. Create an xgen_seexpr node.
  4. Connect the node's Output Value to the Specular Color input of your shader node.

    You can also connect the xgen_seexpr node another color channel, such as Spec1cosine.

    Next, register the expression with the xgen_seexpr node.

Register the noise expression with the xgen_seexpr node

  1. In the Node Editor, select the xgen_seexpr node.
  2. In the node's Attribute Editor beside Expression, type $SpecNoise.

    This points the node to the expression you want it to evaluate.

  3. Beside Customs, type SpecNoise.

    This registers the expression name with the node.

  4. In the XGen window Preview/Output tab, use the slider controls in the Custom Shader Parameters section to adjust the output values of the SpecNoise expression.

Related topics