DOWNLOADS
FORUMS

# Scaling Spheres Uniformly using Expressions

By
-
-
Industry
• Film & VFX
• Games
• Design Visualization
Subject
• Rendering
Products
• Arnold
• Maya
Skill Level
• Beginner
Duration
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:

`\$a=rand(0.1,1);`
`\$a`

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:
`rand(0.1,1)`

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:
`\$a=sphere_size();`
`\$a`

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
Tags
• Arnold
• Maya
• Rendering

Got questions? Visit the Autodesk forums.

Maya 2022

Maya 2020

Maya 2020

## Maya Pro Tips: Hidden and Unknown Maya Tools Every Artist Should Know

0 Comments
To post a comment please login or register