Copying
Copy stamping tutorial
Overview
This tutorial will show the basic use of copy stamping.
You can also see video tutorials about copy stamping in the sidefx.com tutorial section.
Normally, geometry data flows forward (well, downward) through a surface network. A
Copy node takes the “source” geometry from its first input and copies it onto the points of the “template” geometry from its second input.
Stamping lets you communicate information “upstream” to the operators connected to its inputs. This lets you use values defined in the Copy SOP to control parameters on the source geometry as it is copied. You can use this to greatly vary the copies as they are created. Since stamping can affect any parameter on any upstream node, it can vary the copies in any possible way.
In this tutorial, you will learn about
-
Procedural modeling
-
The
$PTexpression variable
Creating a star ball
In this tutorial, you will create a ball of random stars. To achieve this effect, you will…
-
Create a procedural star shape.
-
Copy the star onto the points of a sphere.
-
Use copy stamping to vary the number of points on each star.
Set up the template and source geometry
The Copy operation copies one piece of geometry (the source geometry) onto the points of another piece of geometry (the template geometry).
We’ll start by creating a circle (which we’ll turn into a star later) as the source, and a sphere as the template.
-
In the shelf, click the Create tab, then Ctrl -click the
Sphere to add a sphere at the origin.Ctrl clicking the create tools instantly creates the object at the origin. If you click the icon without Ctrl , Houdini waits for you to place the new object.
-
In the operator controls toolbar (above the 3D view), set the Primitive type to Polygon.
-
In the shelf, click the Create tab, then Ctrl -click the
Circle. -
In the operator controls toolbar, set the Primitive type to Polygon and the Radius to
0.2for both axes. -
Press W for wireframe display so the sphere and star are both visible.
Group the even-numbered points
To turn the polygonal circle into a star, we need a way to scale every other point. A group is a named list of points or polygons (points, in this case).
We’ll use the group feature to automatically create a named group of the even-numbered points and use it in the next step to create the star shape.
-
With the circle still selected, click the Model tab on the shelf, then click the
Group Geometry tool.Group Geometry lets you group together a set of polygons or points so you can refer to them in later operations by name.
-
Press 2 to switch to point selection and select all the points of the circle, then press Enter to finish the selection.
Houdini jumps down into the geometry network of the circle object and adds a
Group node. -
In the parameter editor for the group node…
-
Set the Group Name to
star_points. -
Set the Entity to Points.
-
Set the Operation to Group by Range.
The default settings for “group by range” selects every second point, which is what we want.
-
Make a star
Using the group name instead of a literal list of points gives us more flexibility. Since the group automatically includes every second point, you can go back to the circle node and change the number of divisions, and the transform node will maintain the proper star shape. Houdini makes this kind of procedural modeling easy.
-
Right click the output of the group node and choose Manipulate > Transform, or just start typing “transform” and press Enter when it’s highlighted.
Right-clicking a node output lets you choose a node to add to the output. It’s a shortcut for creating the new node and then connecting it to the output manually.
-
Click the new Transform node’s display flag (the vertical box at the right end of the node).
-
In the transform node’s parameters, set the Scale to 0.3 on all three axes. Set the Group parameter to
star_points.This scales the points in the
star_pointsgroup (which only contains even numbered points) inward, creating a star shape.
Copy the star onto the sphere
-
Click the
Object Selection Mode icon in the toolbox to the left of the 3D view, or press
F8
, to return to the object level. -
In the shelf, click the Modify tab, then click
Copy to Points.Because the star is already selected, Houdini automatically uses it as the geometry to copy. If the Box wasn’t selected when you clicked Copy to Points, you can select it now and press Enter .
-
Select the sphere and press Enter .
Houdini copies the star onto the points of the sphere.
The tool moves the source and template geometry networks into a new object and connects them to a new
Copy surface node. The Copy node only works at the geometry level – it can’t copy top-level objects.The interface automatically goes into the geometry container to show the surface node network.
Create a stamping variable
Stamping is a two-step process. First we create a stamping variable on the Copy node. Then, in the next step, we’ll use the variable in upstream nodes to modify the source geometry per-copy.
The rand function returns a random value. The argument to the function is the seed. Using the same seed always returns the same random number, so you need to vary the seed for each copy. Since the $PT (current point number) is different for each copy, it makes an excellent seed for the rand function.
-
In the network editor, select the
Copy node. -
In the parameter editor, click the Stamp tab.
-
Turn on the Stamp inputs checkbox.
-
Set Variable 1 name field to
starsand the Value 1 field toint(rand($PT) * 6) * 2
This expression generates a random integer from 0-6, then multiplies by 2 to ensure an even number from 0-12. The
$PTvariable contains the point number of the point the source geometry is being copied onto.
Use the stamping variable in the star
Now that the Copy node is making the stars stamping variable available, you can use it to modify the source geometry.
The stamp function retrieves a stamping variable from a node further down in the network. This expression takes the (random per-point) stars variable we set up in the Copy node and uses it as the number of points in the circle (we add 8 to it to ensure a star always has at least 4 points).
-
In the network editor, select the circle node.
-
In the parameter editor, set the Divisions to
stamp("../copy1", "stars", 0) + 8
-
The first argument to
stampis the path to the copy node in which we set up the stamping variable. -
The second argument is the name of the stamping variable to pick up. In this case we only have one stamping variable,
"size". -
The third argument is a default value to use in case the stamping variable we're trying to use doesn’t exist.
-
Finished
You've seen how to
-
Model a procedural star shape
-
Use the Copy to Points shelf tool
-
Use stamping variables to modify the source geometry for each copy
You can use the stars-on-sphere example as a test bed for further exploration of copy stamping. Try varying more aspects of the source geometry using additional stamping variables.