Work with Ptex maps and expressions

Use Ptex maps and expressions together to generate output values for primitive attributes. For example, you can create a Ptex map then use an expression to change how the map's values affect the primitive's color.

Modify a Ptex map value using an expression

After creating a Ptex map, you can use the values it generates as an input to an expression or use an expression to modifiy the Ptex map values.

  1. Click this icon to see the expression created by the Ptex map.

    The Ptex map expression should look similar to the following:

    $a=map('${DESC}/paintmaps/mask');

  2. Create a variable and expression, such as a randomization expression, for the operation you want to perform on the Ptex map output.

    $b = rand(0.2, 1.4);

  3. Combine the variables in an expression to generate the modified output of the Ptex map.

    $a*$b

Combine the effect of multiple Ptex maps

You can create multiple Ptex maps, and then use an expression to combine the maps' effect on the primitives. In this example, the effect of two Ptex maps are combined to control the Preview Color attribute. You can use the same worklfow to create and combine Ptex maps for other primitive attributes.

  1. Click the Preview tab.
  2. Create a Ptex map for Preview Color by doing the following:
    • Beside Preview Color, click this icon .
    • Select Create Map from the menu that appears.
    • Set the Create Map options.
    • Paint the polygon surface with a color you want use as the Preview Color.
    • Beside Preview Color, click this icon to save the map.
  3. Repeat step 2 to create a second Ptex map for Preview Color.
  4. Click this icon to open the XGen Expression Editor.
  5. In XGen Expression Editor, select the Ptex map expression.
  6. Copy and paste the expression into line 2 of the editor.
  7. Edit the expression by doing the following:
    • In line 1, change Color1 to Color.
    • In line 2, change $a to $b.
    • In line 3 type $a*$b.

      This expression combines the Ptex map values.

    • Click Accept.

    In the XGen Editor under Primitive Color, notice that values for two Ptex maps now display.

    There are a number of other ways to combine the Ptex map values. For example, you can add the map values, and then randomize the product by adding $a+$b*rand(0.6,1) to your expression.

    You can copy this expression to other primitive attributes, such as Length, to control their values.

    You can also use an expression to combine the output values of two Ptex maps to generate a number of interesting effects. See Noise expression examples.