Material variations

Once your model is prepared you can create material variables. You declare a variable and it’s type and assign material nodes to it.

CrowdSim3D supports Cycles node based materials. You can add variations on Value, RGB and Image Texture nodes.

Note

Material variations added to armatures also apply to the meshes connected to the character.

Where

In the Properties Space ‣ Object tab ‣ CrowdSim you can define Material Variables.

Creating a material variable

To create a material variable, press Add Material Variable.

../../_images/object-panel-crowdsim-add-material-variable.png
Name
First give your variable a name. Use a recognizable name as this name will also be displayed when using this material variable during population.
Type

You can create 3 types of variables:

  • Value. Selecting this type will vary the value of Value nodes.
  • Color. Selecting this type will vary the colors of RGB nodes.
  • Image. Selecting this type will vary the textures of Image Texture nodes.

Type: Value

../../_images/object-panel-crowdsim-material-variable-value.png

When creating a Value Material Variable you can set the:

  • Range. This configures the minimum and maximum allowed value.
  • Default. This sets the default value for this material variable.
  • Uniform. The values for the Range and Default are real numbers eg 0, 1, 2, 3. If you need fractional numbers you can enable uniform. Uniform will divide the value with the range.

Type: Color

../../_images/object-panel-crowdsim-material-variable-color.png

When creating a Color material variable you can:

  • Add material colors. The selected colors will be used as variations.

Type: Image

../../_images/object-panel-crowdsim-material-variable-image.png

When creating an Image material variable you can set the:

  • Range. This configures the minimum and maximum allowed value.
  • Default. This sets the default value for this material variable.

Adding material nodes

You can add the nodes that will be effected by this material variable. To add a material node to your variable, press Add Material Node. Then select a material and the node.

Be sure that you select a node that is compatible for the variable type.

Compatible node types
Variable Type Node Type
Value ValueNode
Color RGB Node
Image Image Texture Node

In case of a Color material variable you can set the Option Use As Diffuse This will update the viewport color of the selected material as well.

In case of an Image material variable you should also set an Image name field. CrowdSim3D looks at this name and not the filename of the buffer. This field uses a pattern to select an Image Buffer from the Image Editor.

Naming Pattern

The pattern is a Python Formatting string, for example diffuse-{value:03}.png. Here the {value:03} will be replaced by the value selected for this material variable and pre-filled with zeros. When the value is 1 it will look for an Image Buffer with the name diffuse-001.png.

../../_images/image-buffers.png

You can keep multiple textures in sync by adding both Image Texture Nodes to the same Material Variable. This way you can variate the diffuse and bump texture of a material that belongs to each other.

Value and Selected Image Buffers.
Value diffuse-{value:03}.png bump-{value:03}.png
1 diffuse-001.png bump-001.png
2 diffuse-002.png bump-002.png
3 diffuse-003.png bump-003.png

Leading zeros

If you don’t need the leading zero’s you can use a pattern like: diffuse-{value}.png. That will select image buffers with the name diffuse-1.png, diffuse-2.png, etc. If you need more leading zeros you can change it like: diffuse-{value:05}.png.

Leading zeros
Pattern Value = 1 Value = 2
diffuse-{value}.png diffuse-1.png diffuse-2.png
diffuse-{value:02}.png diffuse-01.png diffuse-02.png
diffuse-{value:03}.png diffuse-001.png diffuse-002.png
diffuse-{value:04}.png diffuse-0001.png diffuse-0002.png

Escaping curly brackets

If you have curly brackets in your filename you can escape them by using two curly brackets. For example {{diffuse}}-{value:03}.png will select the image buffer with name {diffuse}-1.png.

Alignment and other options

Other options like alignment can be found at [https://docs.python.org/3.6/library/string.html#formatspec]