1. Create a basic geometry to generate your crowds on. Assuming that the entities are going to be generated inside each faces keep in mind the number of rows and columns.
2. Create a UV offset texture based on the length and width of your grid placement.
//example
writePpmUvFile("C:/test15.ppm", 15, 15);
// 15, 15 being the values of length and width you may change it to your will
// code
global proc writePpmUvFile(string $filePath, int $length, int $width)
{
if ($length > 256 || $width > 256) { error("Too big!!"); return; }
string $fileContent;
// header
$fileContent += "P3\n"; // magic word
$fileContent += ($length + " " + $width + "\n"); // length / height
$fileContent += "255\n"; // max value
// content
int $colorIndex=0;
for ($iL=$length-1; $iL>=0; $iL--)
{
for ($iW=0; $iW<$width; $iW++)
{
int $r = $iW;
int $g = $iL;
int $b = 0;
$fileContent += ($r + " " + $g + " " + $b + " ");
$colorIndex++;
}
$fileContent += "\n";
}
// write file content
$fileId = `fopen $filePath "w"`;
fprint $fileId ($fileContent);
fclose $fileId ;
};
3. Once this .ppm texture is created , convert it in png for example into your favorite image editor.
4. Load the texture in your scene by selecting your placement geometry and creating a
Paint Trigger Zone .
5. Place the crowd by selecting the faces and using the Population Tool
option "Create particles on selected component" .
6. To store the Id of your particles to offset the picture in your signboards create 2
Golaem Attributes and name them "offsetXattr" and "offsetYattr".
7. In your shader scene create a shader for the signboards, using a 2d file texture connected to the shader color attribute. Be sure to map this shader to your Golaem character by going in the Character Maker geometry tab and clicking the reset shader button (save your gcha).
Notice: the placement of the texture depends on the UVs of your signboard, check the UVs and adjust the placement
8. Add two aiUserDatafloat shaders and link them to the UV coord x & y components. This will enable you to control the U & V offset of the texture applied to a particular tile with the offsetX and offsetY attributes. See
this tutorial to learn how to feed the getUserData shader with attributes values. The images in this tutorial are using Arnold, but you can easily adjust it for other renderers.
9. Go to the Geometry Tab in the Character Maker, find the shader assigned to your signboard and add two float Shader attributes to allow it to perform the uv offset: offsetXattr and offsetYattr. You can also use the Reset Shaders button
after selecting the signboard Mesh Asset node. This will add the Shader Attribute nodes automatically. Change the sahderAttribute mode to Attribute and fill in each attribute's name.
11. Edit its Stop Trigger to True for your entities to pass through it and run the other behaviors we may add behind it.
12. From the Channel Operator Attribute Editor, add two Channel Output which you will set as Golaem Attribute, for offsetXPP and offsetYPP
13. In the Channel Operator Editor, add two ChannelOperatorInput to set their value
For offsetXattr
this.paintedColor[r]*255/15
and for offsetYattr
this.paintedColor[g]*255/15
We are working on a texture of 255 different color value for each component, yet we want to divide it to the number of rows of our entity group (15 in this case)
13. Add a
Motion Behavior after the Channel Operator Behavior and load the animation of your crowds proudly rising their sign boards.
13. Edit your simulation to your will and export it using the Simulation exporter (do not forget to export your attributes by ticking the + box icon on the right side of the exporter window.