In this tutorial, we will use XGen to create a complex scene with more than 50 thousand instances of a primitive that itself has over 100 thousand triangles. The final scene has a total of 3 billion visible triangles, and it will render using only 1.2 GB of memory. 

The scene can be downloaded here.


1 - Primitive Archive

Start off by loading the geometry that you want to use as the XGen archive. We will adjust its dimensions later with the XGen Size attribute. You can apply any initial shaders to the model as you will be able to modify them later. Before exporting the archive, to be sure that it is exported to the Arnold format, e.g. the MtoA plugin should be loaded. You should also open the Arnold Render Settings to initialize MtoA settings for the scene. Save the scene before proceeding.

With the geometry selected go to Generate>Export Selection as Archive(s)... Rename the Archive Name to stalagmite and choose to save the archive to the Local Archives folder.


2 - XGen Description

Create a polygon plane. We will use this plane to assign the XGen description. Select the polygon plane and go to Generate>Create Description... This will open up the Create XGen Description. Choose Custom Geometry/Archives. Leave the other default settings alone and click on Create

In the Archive Files section, add the archive that you previously created. You may need to modify the Size attribute below it so that the primitive size fits the scene.

Just now, primitives are randomly scattered over the plane, but with the same size and orientation. We will use one of XGen sample expressions on the Twist attribute to add some randomness to the orientation:

Under Primitive Attributes, click on the downward pointing arrow to the right of the Twist slider control. Select the following from the menu: Load Expression>samples>Geometry>flatten_RoomYou should see Width and Depth attributes appear under Twist. Increase the Twist Width to at least 200.


3 - Density  

You may need to change the Density value depending on the values that you have used in the expression editor. If the stalagmite archives are too densely packed together, you may want to reduce the density value. Conversely, if they are too far apart, you may need to either increase the density or decrease the maximum width size. The image below shows the effect that increasing the density has on the number of primitives created by XGen.

A common issue is that your scene may have too many primitives and that slows down the Maya viewport performance. In the XGen Preview/Output tab, you will be able to decrease the Percent attribute in the Preview Settings section. This reduces the number of primitives being represented in the viewport while still being able to render all of them when invoking Arnold.   


4 - Modify attributes with a texture map 

We can control the length (height) of the primitives 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 to the right of Length. Select Create Map... (it is important to note that this only works if the plane has a Maya shader assigned to it). Increase the Map Resolution to around 200. Then, click on Create. 

You should see in the Hypershade or Node Editor windows that a file texture node 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 primitives. To update the file texture in XGen, you will have to click on the disk icon at the right of the length attribute control.

Now high values go from 0 to 1. We want to change this range and add a bit of randomness to the primitive height. We can do this by modifying the current Length expression.

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:



Add the following line in the Expression Editor before the last line: $a = 2*$a + rand(0,0.75); Now the primitives will have a length ranging from 0 to 2, and an additional random value between 0 and 0.75 will be added. Click Accept when you are done. 

5 - Lighting and Camera DOF

We will use an AiSkyDome light to light the scene. In the Arnold menu, select Arnold>Lights>SkyDome Light. Connect a file texture to the Color attribute of the sky dome light and choose a suitable HDR map. Adjust the Exposure in the Arnold settings of the sky dome light so that the scene is evenly lit. To reduce any shadow noise in the scene, increase light Samples to 3. We will add some depth of field to the camera to simulate a macro photography shot. Position the camera close to the XGen description. You will also need to increase the focal length of the camera. In the final image, a value of 65mm was used. Select the camera and go to the Arnold settings. Select Enable DOF and choose a focus distance. To add shallow depth of field to the camera, increase the Aperture Size. You will need to adjust this value according to the size of your scene.


6 - Rendering

You should be using IPR to test render the scene. Using IPR rendering with MtoA allows you to interactively update the lighting, cameras, and shaders in your scene with fast feedback. You may need to refresh the IPR after making any adjustments to the XGen description. Once you are happy with the look, you are ready for a final render. Increase the Camera(AA) samples to around 7 or 8. You may need to adjust this value depending on how much noise is visible in the areas of the image that contains camera DOF. If you experience any noise in the indirectly lit areas of the scene, try increasing the Diffuse (GI) samples to 2 or 3.


This tutorial was printed in issue 189 of 3D World magazine.

  • No labels
Privacy settings / Do not sell my personal information / Privacy/Cookies