XGen is an arbitrary primitive generator used by Walt Disney Animation Studios
for films such as Tangled™, Frozen™, and Big Hero 6™.
Some typical uses for it include hair generation or set dressing.
However, you can also use it to create interesting works of art
like those of featured artist Lee Griggs.
These works are inspired by the various interesting topologies found in nature,
like permafrost or bacterial cultures.
In this movie, we'll use XGen to generate similarly styled artwork
using nothing more than primitive cubes.
Create a new project named “HTM_XGen_topology”.
We'll start with an empty scene.
First we'll need an object on which to attach our XGen description.
For a review of basic XGen functionality, refer to the "Creating XGen Hair" tutorial series.
Create a polygon plane.
Rename it "base_GEO" and scale it 120 units in all axes.
Select it and open the XGen window.
Create a new description. Rename it "topology_art"
and rename the collection "topology_collection".
Instead of splines, which are good for hair, we're going to generate custom geometry.
Leave the remaining controls as they are and click "Create".
Maya creates a new xgen node hierarchy.
However it also displays an error indicating the "Archive file list is empty".
This is because we haven't specified the type of geometry we'd like XGen to generate yet.
Create a polygon cube.
Rename it "cube_prim_GEO" and translate it 0.5 units in Y so it sits on top of the plane,
then freeze its transforms and delete its history.
In order to instance this cube across the base_geo object,
you first need to create an archive file from it.
Before you can do that, you must first save the scene.
Go to the Archive Files section of the XGen window's Primitives tab.
Select the cube and click Create From Selection.
Store the archive in your local destination folder and rename it "cube_prim", then click Export.
Now we can load the archive file by clicking the Add button
and navigating to the xgen\archives folder of your project.
Note that Maya also exported additional files related to the archive,
such as a Maya scene containing the referenced material.
However, since we didn't create a specific material for our cube
choose not to import this file.
We'll adjust the shading later using the default phen shader.
Maya populates the plane with a tight grouping of cubes.
This grouping is far too dense though, so reduce the Density attribute by half.
Now we need to break up the cubes’ uniformity
by adding some variation to their geometry and arrangement.
Let's start with their height, which we can adjust with the Length attribute in the XGen window.
Click the dropdown button next to the Length attribute and create a map.
We're going to paint a ptex map on the plane to vary the heights of our cubes.
Rename the map "cube_length" and increase Map Resolution to 200.
Hide the XGen preview and open the 3D Paint Tool.
In a length map, white refers to a primitive's full length while black refers to 0.
Make sure you are in textured view,
then paint a design on the plane using various shades of grey.
When you're finished, click the save button next to the Length attribute to save the map.
Maya automatically regenerates the XGen preview.
Notice the cubes vary in length depending on the part of the map they're sitting in.
However, the difference in height isn't very dramatic given their short length.
Let's modify the expression to make the results a little more obvious.
Click the Expression button next to Length to open the Expression Editor.
Add the following line between lines 1 and 2.
This multiplies the result lengths 20 times over before displaying them.
Now we get much more discernible peaks and valleys.
You can change the pattern of primitives at any time by hiding the XGen preview,
then using the Show Maps button next to the Length attribute to display and modify the map.
Just make sure to save the altered map each time you do.
Despite the varied heights, the cube's arrangement is still a bit too uniform.
Let's twist some of the primitives around to add even more variation.
Click the dropdown next to the Twist attribute and select
Load Expression > samples > Geometry > flatten_Room.
This preset twists each primitive around its center at specific intervals,
which you can adjust via the Twist Width value.
For now we'll leave it at 200.
This makes for a pretty neat still shot,
but we can take it even further by animating it via its expression.
Open the Length attribute's Expression Editor.
We can add the $frame variable, representing the current time slider frame,
to our existing length expression.
Play the scene to see the cubes "grow".
We can also subtract from the current frame, in essence getting a negative frame,
to offset our scaling factor of 20 so the primitives grow from zero.
You can add a similar expression to the Twist attribute to spin the primitives as they grow.
In this case, we'll attach a multiplier to the frame value since a twist of 1 is barely noticeable.
Finally, the fact that all our primitives grow at the same rate is a little dull.
This is because we're incrementing all the heights uniformly.
Instead, let's try increasing them exponentially.
This way, the primitives in the white areas of the ptex map will grow faster
than those in the dark areas.
You can then use the root_color Custom Shader Parameter to color the primitives
and create a Physical Sun and Sky lighting setup to light the scene for your batch renders
in your renderer of choice.
For more information on these two processes, refer to the "Creating XGen hair – Part 6"
and the "Lighting a scene naturally for mental ray rendering" tutorials respectively.
At the beginning of this tutorial, we mentioned how this kind of topological art
is inspired by formations you see in nature.
We can actually leverage data culled from those formations in the real world
to help with our art too.
In this case, let's use this topographical map of the Grand Canyon,
provided by the Shuttle Radar Topography Mission,
to power your XGen description.
Hide the topology_art description.
Create a new XGen description on the same plane.
Rename it appropriately based on the topographical map you find.
In this case, we'll name it "topology_canyon". Store it in the same collection.
As before, make sure the primitives are set to use custom geometry.
And add the cube archive file.
Create a new length map for this description. Rename the map "canyon_length".
This time instead of painting a map, we'll load a file as our ptex map.
In the Outliner, turn off Display > DAG Objects Only.
Select the file node pertaining to our second length ptex map.
In the Attribute Editor, load the Grand Canyon radar data.
Return to the XGen window and save the map.
And like before, add an exponential expression so the height variations are more obvious.
The data looks a little deformed here, so set the plane's Scale X attribute to 240.
Feel free to adjust the primitive’s Width and Depth attributes,
as well as the Density to further refine your scenery.
By generating a ptex map for the root_color Custom Shader Parameter
and using the same procedure, you can apply a colored version of the same topographical map
to get a nice rendered color.
Or you can free style paint it as you did previously to generate your own looks.
Try using this method to create interesting patterns out of anything,
from images of bacterial cultures to relief maps of the moon!