Saturday, December 23, 2017

Parametric Modeling with Modifiers

Modifiers in Blender are powerful tools that help achieve fast various goals. From shaping and modifying mesh objects, transferring data between objects, animation based on specific properties. Even physics simulations like particles, cloth and fluids are part of the modifiers family.
One interesting aspect of modifiers is that you can stack them on top of each other affecting the result from the previous modifiers.
This gives opportunity to create parametric models which is a way of nondestructive modeling.
Simply start with primitive object element and build up towards more complex structure using only modifiers and helper objects like Empties and Textures.
In this tutorial I will show you an example of parametric modeling with modifiers.

We will build a sphere from single plane and will add custom properties that will drive some parameters of the sphere.

If you feel impatient to read through the tutorial you can download the final blend file at the end of the page. But I strongly advise you to go through the steps if you want to learn how the sphere was constructed.

Let' s Begin!

Empty your scene from any objects or start on an empty layer

Creating the Plane

Press Shift+A and select Mesh -> Plane.
This will add a Plane object that by default is oriented with face pointing in Z direction (Fig. 1)

Figure 1. The good ol' Plane

In order to continue with building the parametric sphere rotate the Plane along X axis by 90 degrees and Apply the Rotation. With the Plane selected press - R then type - X, type - 90 and press Enter, to apply the rotation press Ctrl+A and select Rotation)
The Plane's local axis should look like in Fig. 2

Figure 2. The plane rotated 90 degrees around X axis. Don't forget to apply the rotation!

Adding the Modifiers

All modifiers can be added from the Add Modifier menu in Modifiers Tab in Properties Editor (Fig. 3)

Figure 3. The Great Add Modifiers menu.

Adding Displace Modifier

Displace Modifier basically shifts the vertices of the object by given rules.

In our case we need to move the whole plane half width (which is 1) to the left on the X axis.
Select the Plane object and add a Displace Modifier with the following settings (Fig. 4):

Direction: X
Midlevel: 0

Figure 4. Our first modifier shifts the Plane to the left of its origin.

Adding second Displace Modifier

Press the Copy button to duplicate the modifier.
In the new Displace Modifier change Direction to Z (Fig. 5)
The Plane should move 1 unit along Z axis

Figure 5. This time let's move the Plane 1 unit along Z axis.

Adding Array Modifier

Array Modifier duplicates the object or the result from the modifier's stack by given number and direction condition.
With the Plane object selected add Array Modifier and enter 12 (for now) in the Count field
Also enable Merge (not shown in the figure)
(Fig. 6)

Figure 6. We continue bay making a stripe of planes using Array Modifier.

Tip: To view the edges of the object enable Wire and Draw All Edges in Display panel of the Object Tab

Adding Simple Deform Modifier

Simple Deform Modifier performs space warping operations on the object vertices. In our case we need the strip to bend and to form a half circle. Add Simple Deform Modifier, press Bend button and enter 180 in Angle field (Fig. 7).

Figure 7. Bending the stripe with Simple Deform Modifier into half circle.

Tip: Bending works by placing the center of deformation at specified origin (center of the object or another one). Then it uses the axis orientation to perform the bend. It takes the vertices and swirl them around Z axis of the object by given angle. In our case the strip is bent to form a half circle.

Creating first custom property

The procedure of adding a custom property to the object is described in my tutorial

Create an array of planes that fits inside of Camera View using Drivers

Create a custom property that will represent the half of the faces in a sphere ring, respectively the half of the columns and name it half_cols (Fig. 8). Enter the settings as shown in the figure.

Press N in the 3D View to open the Properties shelf and open Properties panel.

Adding Driver for the columns

In the Array Modifier panel press Ctrl+D over the Count field and select Single from Target.
With the Picker click over the half_cols property. Increase the number of half_col to 12.
You can open additional Graph Editor to edit the Drivers (Fig. 9)

Figure 9. Create a driver for the Count property of the Array Modifier and link it with the half_rows custom property of the Plane. In this way we won't dig into the modifier stack to change this value.

Adding third Displace Modifier

We need to shift the bent stripe along Y axis so the center of the plane coincides with the center of the half circle.
The Bend Modifier takes the initial length of the stripe from the Array Modifier and bends it into half circle. The length of the stripe is:

length = 2*n ,where

2 is the width of the Plane
n is the number of Array copies

So the radius of the half circle should be:

radius = length/pi or

radius = (2*n)/pi ,where

pi is constant

Add new Displace modifier, set Direction to Y, Midlevel to 0. Add driver - Single from Target to Strength property and pick half_cols property.
Select the Strength channel in Drivers window of Graph Editor and enter the expression:


 as shown in Fig. 10

Figure 10. Using driver to move the half circle so its center coincides with the Plane's origin

The half circle is centered correctly. You can test if everything works by changing the half_col value.

Adding second Array Modifier

Add second Array Modifier but this time set the Relative Offset to be 1 along Z axis.
Enable Merge option (Fig. 11).

Figure 11. Second Array Modifier duplicates the half circle along Z axis.

Creating second custom property

The second custom property of the Plane object will control the count of the second Array Modifier (Array.001) and will represent the number of rows in the sphere. Enter the following settings for that property (Fig. 12)

Figure 12. The second custom property of the Plane - rows, will control the number of sphere rows.

Adding Driver for the rows

Open Array.001 modifier panel and add driver  - Single from Target and pick rows custom property.
Set the rows custom property to 12 (Fig. 13)

Figure 13. The second driver will link the number of  rows to the Count of the Array.001 modifier.

Tip: Sometimes the Drivers don't update immediately - changing the frame on the timeline will refresh the Drivers.

Adding second Simple Deform Modifier

In order to bend the half cylinder the Plane axis won't work. We need to bend the cylinder from the bottom and far left side of the half cylinder. For this we need an Empty object to control the bending axis and origin.
Add Empty object.
Add second Simple Deform modifier to the Plane.
Set the Empty as Axis, Origin and set the Deform Angle to 180 (Fig. 14)

Figure 14. Second Simple Deform will bend the half cylinder into half torus shape.

The bent half cylinder looks strange. We need to rotate the Empty in the correct orientation.
Select the Empty and type in the Properties shelf, in Transform panel, in Rotation fields the following values (Fig. 15):
X: 90
Y: 90

Figure 15. With the help of the Empty object the bending looks better.

Adding Driver for the displacement Strength

For the X location of the Empty we will add driver that will place it to the far left side of the half cylinder.
Right click over X location field of the Empty and add driver - Manually Create Later (Single).
Click the X Location channel in the Drivers Graph Editor and change var to Single Property variable. Select Plane as Object and in Path type: ["rows"]. In the Expression field type:


which is the radius of the outer circle of the donut.

Change the rows custom property to see the Empty shifting along X axis and the half cylinder bending into half sphere (Fig. 16)

Figure 16, From half donut to half sphere - that's the power of drivers!

Tip: While changing the custom properties the half sphere will not close properly because of drivers not refreshing properly. Changing a frame on the timeline (with arrows keys) fixes this problem and refreshes the model shape.

Adding Mirror Modifier

The Mirror Modifier duplicates and flips the object over defined axis. Select the Plane object and add Mirror Modifier - disable X and enable Z axis. You should get the full sphere (Fig 17)


Figure 17. Using Mirror Modifier we complete a full sphere.

If you play now with the custom properties you will notice that the sphere changes its rows and columns but also its size. Let's fix that.

Adding Cast Modifier

The Cast Modifier takes the vertices of the object and from given center and radius moves the vertices to shape Sphere, Cylinder or Cube
We already have spherical object but in this case we will use the Cast Modifier to restrict the radius of that shape to desired value.
Add Cast Modifier to the Plane object.
Disable From Radius, set Factor to 1 and for Size type 2 (Fig. 18).

Figure 18. Using Cast Modifier we restrict the radius of the sphere to constant while changing the custom properties - rows and half_cols.

That's it!

We made a parametric sphere and we can control the number of polygons however we want.

Tip: To convert and collapse all modifiers and turn the parametric sphere into real mesh press Alt+C - Mesh from Curve/Meta/Surf/Text. This will erase all modifiers but will keep the sphere with the last settings.

Tip: You can add additional custom properties to the Plane for different modifiers parameters like bend angles, relative offsets and animate those custom properties to make crazy animations. Like this:

Download the final blend file!

No comments:

Post a Comment