Scaling Spheres Uniformly using Expressions

Login to Follow
  • Film & VFX
  • Games
  • Design Visualization
  • Rendering
  • Arnold
  • Maya
Skill Level
  • Beginner
15 min

In this short tutorial you will learn how to randomly scale the size of Sphere Primitives uniformly using Expressions.

  • Start off by creating a polygon plane with which we can assign the XGen description. Scale the plane to 10 in X,Y and Z.Increase the subdivisions of the plane to 10 in Width and Height.

  • With the polygon plane selected, go to Generate> Create Description...
  • The Create XGen Description will appear asking What kind of Primitives are made by this Description? Choose Spheres and Generate the Primitives - Randomly across the surface.

  • Increase the Density to around 100. You should see the plane fill with spheres as in the image below.

If you was to add a typical random expression like the following to each of the Length, Width and Depth attributes you would see that it randomly scales the spheres in non-uniform directions:


Spheres are randomly scaled individually in length, width and depth

A way to scale the spheres uniformly in all directions is to create an attribute under the Expressions tab that we can call from the Primitive Attributes.

  • Go to the Expressions tab and enter sphere_size in the Name attribute. Make sure it is set to float and click on the icon in order to create the attribute.

You should see the new float attribute sphere_size has been created underneath.

  • Enter the following exression in the text field:

These values will determine the global range of the size of the spheres.

  • Now replace the previous expression with the following in the Length, Width and Depth attributes:

You should see that the spheres are now randomly scaled uniformly in all directions:

That concludes this short tutorial on how to uniformly scale spheres using expressions. If you want to randomly change the color of the spheres as in the example images, then you should read this tutorial - Assigning Random Colors to Primitives. To learn how to assign color texture maps to the spheres, you should read this tutorial - Assigning Color to Primitive Archives.

Further examples

Thanks to Pedro Fernando Gómez for his assistance with XGen.

Posted By
  • Arnold
  • Maya
  • Rendering
To post a comment please login or register