Managing Shaders

Shaders Management Overview

Shaders define the appearance of Crowd characters at render time. Each mesh can have one or several shaders attached to it. Golaem Crowd can handle two types of shaders:
  • surface shaders: these shaders can be handled by all renderer plugins. A surface shader corresponds to the surface material attached to a Maya shading group. It defines how the surface of a mesh reacts to the light in the environment. A shader is considered a surface shader if its category contains the keyword surface.
  • contour shaders: these shaders are only relevant when rendering with Mental Ray. They define how the contours of characters are drawn at render time. A shader is considered a contour shader if its category contains the keyword contour.
  • Surface and contour shaders are automatically detected when adding a mesh asset. To view and edit the shaders of a mesh asset, expand the mesh asset item in the Assets tab and select the shader. At the bottom of the view, a Shader Asset button will appear. Clicking on it will expand the shader asset view.
To create a new shader and assign it to a mesh, select the mesh and click on the + button in the Assets tab. You will be prompted to enter the name and the category of the shader if the shader doesn't exist. If the shader already exists, it is reused and the category and its attributes will be filled automatically. To remove a shader, select it and click on the - button in the Assets tab. Meshes with no shader will be rendered with the default shader of the renderer.
 
Assets Manager - Shaders View
 
Shaders can have several Shader Attributes. By default, shaders are created with no attribute. Shader Attributes are shown in the Shader Attributes group box. To add a new shader attribute, click the New… button and select the type of shader attribute to add. Two types of shader attributes are currently supported: integers and floats.
 
Assets Manager - Adding a shader attribute
 
By default, both for integer and float attributes, the value of the attribute passed to the shader during the rendering process is chosen randomly between a minimum and a maximum. If the minimum and maximum values are equal, the value of the attribute will be constant among the meshes that use it. It is also possible to use the value of a PP (Per Particle) attribute instead of a random value. To do so, check the Use value from PP attribute checkbox (this will disable the Minimum Value and Maximum Value controls) and enter the name of the PP attribute. The following example shows a shader with two attributes, an integer and a float one.
 
Assets Manager - Shader attributes
 
To remove a shader attribute, simply click on the orange cross button on top of its name.
 

Shader Templates

The attributes of a shader asset can be exported to a .cst file (Crowd Shader Template) to be used on another shader asset. To export the attributes of a shader asset, click the Export Template button in the Shader Asset view. The shader template can be saved as a .cst file (see Figure 177).
 
Assets Manager - Export shader template
 
To apply a shader template on another shader asset, select it and click on the Import Template button. Once the .cst file is selected, a dialog will prompt the user to select the shader attributes to import. Attributes with the same name will be overwritten.
 
Assets Manager - Import shader template
 

Assigning a Shader Asset on Multiple Meshes

To assign or unassign a shader asset on several meshes, select it and click the Assign… button. A list will display all the meshes used in the Assets Tool, prefixed by the name of the character. All the meshes that use the shader asset are highlighted in this list (see Figure 179). To add/remove a mesh to/from the selection, click on it while holding the Ctrl key.
 
Assets Manager - Assign shader asset on meshes
 
Once the assets are created, the user can move on to define the Rendering Types
 

Resetting Shader Assignments

To reset the shader assignments of a mesh according to the Maya scene, select the mesh in the Assets tab and click on the Reset Shaders button (   icon), or select the menu Tools/ Reset Shaders. Shader attributes and categories are conserved if the shader already exists. This also works when selecting a mesh asset, an assets group or an entire character. All shader assignments of the meshes under the selection are reset.