Scene formed of XGen 'archive' cube primitives. A texture map drives the 'length' attribute, and an expression drives the 'twist' attribute.
XGen is a powerful tool that offers many creative opportunities for positioning an arbitrary number of primitives either randomly or uniformly placed. You can use texture maps in combination with XGen Descriptions to specify the location and density of primitive generation as well as to control the number of primitive attributes.
This tutorial will show you how you can very easily use a texture map to 'drive' the length of an XGen primitive. These primitives can range from spheres, splines or as in the example below, cube geometry that has been exported as an archive. We will then use the $frame expression to animate the length of the archives. Finally, we will talk about how to batch render the animation using XGen and MtoA.
A video tutorial that goes through this process can be found here.
- Start off by creating the polygon cube that you want to use as the XGen archive. Leave the cube's scale at 1,1,1. We will adjust this later with the XGen Size attribute.
- With the cube selected go to Generate> Export Selection as Archive(s)...
- Rename the Archive Name to cube and choose where you want to save the archive file.
- Create a polygon plane. We will use this plane to assign the XGen description. If you want the formation of the XGen primitives to be circular, then make sure the Subdivisions Width and Subdivisions Height are set to 1. If you want the formation to be square, then increase the Subdivisions Width and Subdivisions Height to 10. In this example, we have set them to 1.
- Select the polygon plane and go to Generate> Create Description. This will open up the Create XGen Description below.
- Choose Custom Geometry/Archives. Leave the other default settings alone and click on Create.
- It is good practice to lower the Percent value in the Preview/Output tab before continuing. If the Percent value is too high, you may find that your computer will stall due to a large number of primitives generated.
Under Primitive Attributes, click on the downward pointing arrowto the right of the Twist slider control.
Select the following from the menu:
You should see Width and Depth attributes appear under Twist. Increase the Twist Width to at least 200.
You may need to change the Density value depending on the values that you have used in the Expression Editor. If the cube archives are too densely packed together, you may want to reduce the Density value. Conversely, if the cubes are too far apart, you may need to either increase the density or decrease the maximum width size. The images below show the effect that increasing the Density has on the number of primitives created by XGen.
- Doubling the Density value to 70000.0 produces the image below.
We can control the length (height) of the cubes using a combination of texture maps and expressions. We will start off by creating a texture map to control their length.
- Click on the downward pointing arrow t is important to note that this will only work if the plane has a Maya shader assigned to it). to the right of Length. Select Create Map... (i
- The Map Name should say 'length'. Increase the Map Resolution to around 200. This sets the resolution of the PTEX map in texels per-face. When using high-resolution textures, use larger Map Resolution values. After you have done that, click on Create.
Now we want to add our texture map. Click on the paint icon to the right of the slider control. You should see in the Hypershade and Node Editor windows that a file texture has been connected to the plane.
- Select the file texture and open the texture map that you want to use to drive the length of the cube primitives. Make sure to choose a texture map that has a lot of contrast and whose features are recognizable even at a small size. Too much incidental detail in the image will not transfer across well to the cubes.
Black and white texture used to drive 'length' of cube archives (map used for top page image).
- Before we render the scene we must first tell XGen to update the file texture. Do this by clicking on the disk icon for each length, width and depth attribute. Create a light and render the scene.
Remember to select thedisk icon after updating the file texture used to define the primitive attributes. Otherwise, XGen will not update it, and the render will not change.
- Next, click on the Expression icon to the right of the Length slider control.
- You should see the following length expression text in the Expression Editor. In the Expression Text Field you should see the following text:
This is used to define the length attribute using the texture map, and 200 is the Map Resolution that we defined earlier.
- Add the following line in the Expression Editor.
...where 20 is the maximum length of the cube archive and 1 is the minimum size. Your length Expression Editor should look like the following image. Copy the expression text. Click Accept when you are done.
- Paste the same expression that we used for the length here. Do the same for the Depth attribute.
We can use the $frame expression to add some animation to the length attribute of the XGen cube archive.
- Open the Expression Editor for the length attribute and add the following in the Editor window:
- You may want to increase 20 to a higher value such as 40 in order to increase the size of the length attribute. Click on Accept. You should see that a slider called Frame has been created.
- Go to frame 1 in the Time Slider. Right click on Frame and choose Set Key. You may need to use a negative value so that the cubes start off with zero length.
- Go to the end frame (for example 100) and create another keyframe for Frame (something like 25). Scrub through the Time Slider to view the animation. You should see that the cubes seem to grow in length during the animation.
- You can also try keyframing the Twist Width attribute to see the cubes twist into interesting formations. The example below uses values between 200 and 600.
Remember to do the following steps before batch rendering otherwise the XGen description will not render:
- Save the scene.
- With the geometry and XGen description selected go to File>Export Patches for Batch Render from the XGen description menu. If the XGen description has animation, enable animation and choose the Frame Range. Ensure that you have the AbcExport.mll loaded in the Plug-in Manager otherwise it won't export the animation properly.
- Save the scene.
- Once you are happy with how the animation looks, you are ready to set off a batch render animation.
That concludes this tutorial on animating formations of XGen primitive archives with texture maps and expressions. This is just one example of what this powerful tool is capable of. Try experimenting with different texture maps and primitive types such as splines and spheres. Below are some further examples using various textures connected to the length attribute.
Thanks to Pedro Fernando Gómez for his assistance with XGen.