The following example shows how to export vertex colors; additionally, the RenderMan Code node will be used to visualize the color sets in a rendered image.
  1. Create a polygon shape of your choice, and light it with a few spot lights.
  2. Select the polygon shape and select the Polygons menu set.
  3. In the Color menu, select Color Set Editor.
  4. In the Color Set Editor, create 2 color sets using the New button.
  5. Name a color set 'surfaceColor' and name the other color set 'displacementColor'.
  6. Select the 'surfaceColor' color set.
  7. In the Color menu, select the Paint Vertex Color Tool item.Paint the surface as you like, leaving some visible areas unpainted. Avoid using the Flood button. You can try varying the opacity slider while painting in ‘RGBA’ mode.
  8. Back in the Color Set Editor, select the displacementColor color set.
  9. Since we are only going to use the alpha channel of this color set, use any color you want, but make sure the Channels radio button is set to ‘RGBA’. The surface is going to be displaced where you paint; you can adjust the Opacity slider and check the Accumulate opacity checkbox if you want.
  10. Bring up the Hypershade Editor and create a surface node, such as Blinn.
  11. Create a RenderMan Code node (listed in the Utilities section) and then select the RenderMan Code node and bring up the Attribute Editor.
  12. Click on the Text Editor button next to the Shading Parameters text field and append the following lines in the text editor:

    shader_input varying color surfaceColor
    shader_input varying float surfaceColor_alpha
    color defaultColor
    output color outColor

    The first line defines a RGB color input parameter that varies for each vertex. Since it is named identically to a color set that we will export, the painted colors of that color set are passed automatically to it. The second line defines an input parameter for the alpha channel of the 'surfaceColor' color set. Note that the RGB data is exported to a variable named identically to the color set, while the alpha channel is exported to a variable that has '_alpha' appended to the color set name. The third line defines a color input plug for the RenderMan Code node. Finally, the last line defines an output plug in the same fashion.

  13. Click on the Text Editor button next to the Shading Code text field and append the following lines in the text editor:

    outColor = mix(defaultColor, surfaceColor, surfaceColor_alpha);

    This line of code simply assign to the 'outColor' plug a mixture of the colors 'surfaceColor' and 'defaultColor' based on the alpha channel of the 'surfaceColor' color set.

  14. Back in the Hypershade editor, connect the 'outColor' plug of the RenderMan Code node to the color input plug of the Blinn node.
  15. Create a 2D Texture node, such as Fractal, and connect its color output plug to the 'defaultColor' input plug of the RenderMan Code node.
  16. Create a Displacement node.
  17. Create a new RenderMan Code node.
  18. Select the new RenderMan Code node and bring up the Attribute Editor.
  19. Click on the Text Editor button next to the Shading Parameters text field.
  20. In the text editor, append the following lines: 

    shader_input varying float displacementColor_alpha
    output float displacement

    These lines defines the following: the first line defines a float parameter that varies for each vertex. It will automatically receive the alpha channel of the 'displacementColor' color set. The second line simply defines a float output plug. 

  21. Click on the Text Editor button next to the Shading Code text field. In the text editor, append the following line: 

    displacement = 2 * displacementColor_alpha;

     This line simply assigns to the displacement output plug two times the alpha channel of the 'displacementColor' color set. Note that you can increase or decrease the multiplier value to make the displacement more or less obvious.

  22. Connect the 'displacement' output plug of the RenderMan code node to the 'Displacement' input plug of the Displacement node.
  23. Connect the 'displacement' output plug of the Displacement node to the 'displacementShader' plug of the shading group connected to your surface node.
  24. Assign the material you just created to your polygon shape.
  25. Because we are doing displacement, we need to specify a displacement bound. Bring up the Assignment Panel by selecting its entry in the 3Delight menu (or by clicking on the Assignment Panel button in the 3Delight Shelf).
  26. Make sure your polygon shape is selected.
  27. In the Assignment Panel, create a geometry attribute node by clicking on the texture button next to the Attribs option menu.
  28. Click on the AE button to edit this node in the Attribute Editor.
  29. In the Displacement group, assign a value for the 'Displacement Bound' attribute. The value should be as high as the maximum possible displacement value, so it is safe to assign here the same value as the multiplier used in the RenderMan Code above (in this example, the multiplier is ‘2’).
  30. Choose the 3Delight > Render menu item to render your masterpiece.