Home Modeling 

Copying and Instancing

Overview

Houdini has a few functions for duplicating geometry:

  • Copy and paste.

    You can select an object in the viewer, press Ctrl + C to copy the object to the clipboard, then Ctrl + V to paste a copy of the object.

  • Duplicate surface node. This is a simpler variation on the Copy surface node. It lets you create multiple copies of its input geometry with transforms applied to each copy.

  • Copy node. This has functionality similar to Duplicate to create multiple copies with transformations applied to each.

    However, its main function is to copy a piece of source geometry onto each point of some destination geometry, optionally with modifications based on attributes on the destination points.

    This is a very convenient way to create regular patterns of objects (for example, at the corners of a box or distributed across the surface of a sphere) or random placement of objects (for example, a forest or a star field) using irregular surfaces or the Scatter SOP.

    The Copy to points tool on the Modify shelf tab lets you select source and destination geometry and creates a Copy node for you.

  • Object instancing and point instancing. An object instance or point instance gets its geometry from another object but has its own transforms.

    Create an Instance object at the Scene level. The Instance geometry container object is a normal geometry container with extra instancing-related rendering properties added for you.

    • To instance a “source” object, set the Instance object parameter on the Instance tab of the Instance object’s parameters.

    • To instance the source object onto every point of the geometry inside the Instance object, turn on Point instancing on the Instance tab of the Instance object’s parameters.

Copying vs Instancing

The copy node creates copies of the source geometry on each point of the destination geometry. It creates actual geometry in the scene you can then model with, but it increases the amount of processing Houdini has to do to cook and display the scene.

See the Copy tool and the Copy node help for more information on copying.

Point instancing copies the geometry at render time, so each copy only exists momentarily as its area of the image is rendered. The geometry only appears in the render, not in the viewer.

Using Copy as a preview for instancing

Normally, point instanced geometry is only visible at render time. However, you can use the Copy node to visualize instancing in the viewer.

The basics

This is the basic procedure, which you can accomplish using various configurations of nodes and references depending on your scene. An example follows that shows a good concrete way to implement this technique.

  1. Create an object containing the geometry you want to instance onto points.

  2. Create an Instance object container. Turn on point instancing on the object and set the object to be instanced.

  3. Inside the Instance object’s surface network, set up the template point geometry you want to copy onto. This is the geometry to render.

  4. Branch the point geometry off to a Delete node node. On the Delete node, set the Entity to Points. On the Number tab, set the Operation to Delete by range.

    Because copying geometry is much more memory and processor intensive than instancing, for large data sets you’ll only want to preview a small percentage of the total number of points.

    Use the Start/End and Select n of m controls to reduce the number of points in the template geometry.

    For example, to see a representative sample of the template points, set Select n of m to 50, 100 to delete 50% of the points (or use 80, 100 to delete 80%, and so on).

    To all but the first 100 points, set Select n of m to 1,1, then set Start/End to 100, $N ($N represents the total number of points). To see the last 100 points, set Start/End to $N-100, $N. To see the middle 100 points, set Start/End to $N/2-50, $N/2+50.

  5. Connect the Delete node to the second (template) input of a Copy node. Connect the first input to a node containing the same source geometry you set on the Instance object (probably using an Object merge node, which imports geometry from another object).

  6. Make sure the Copy’s output is the display geometry and the un-reduced geometry (from before the Delete) is the render geometry, using the display and render flags. See below for an example.

Example

This is the surface network inside an Instance object with point instancing turned on.

We scatter a large number of points across a grid. These are template points we want to instance onto.

From scatter1, we branch off to a Null representing the geometry to render, and a preview branch that ends in a Null representing the display geometry. Ending the chains with nulls lets us insert and wire nodes upstream without having to move the display and render flags around. For information on how to set the display and render flags, see the section on surface nodes.

In the “display” branch (on the left side in the screenshot), we start with a Delete node to reduce the number of points (see above for how to set its parameters). Then we use object_merge1 to merge in the same object we are instancing, and copy1 copies that geometry onto the reduced points from delete1.

Motion blur of intanced geometry

Houdini has two main types of motion blur: transform blur and deformation blur. Deformation blur is much more intensive to calculate, but is necessary if you want an object’s shape changes to blur, not just its motion through space.

  1. Turn on Allow motion blur in the render node.

  2. If point instanced geometry changes shape over time and you want the shape changes to blur, on the Instance object set Point motion blur to Compute sub-frame geometry (deformation) (under the Point instancing checkbox).

Render properties on the source object/geometry also affect the motion blur of the instances.

Copy stamping

Copy stamping is a feature of the Copy node that lets you modify the input geometry for each copy. Copy stamping involves setting up two things:

  • On the Stamp tab of the Copy node, turn on Stamp inputs and use the Variable/Value fields to set up per-copy values. (The $PT local variable in expressions gives the current template point number. The $CY local gives the current copy number. See the Copy node help for a list of all local variables.)

  • In the upstream nodes that generate the copy geometry, use the stamp expression to grab the value of the stamping variable from the Copy node to use in an expression.

See the Copy node help for more information on stamping.

Instancing point attributes

When you copy or instance geometry onto points, Houdini looks for specific attributes on the destination points to customize each copy/instance.

Attribute nameData typeDescription

orient

float4 (quaternion)

Orientation of the copy*

pscale

float

Uniform scale

scale

float3

Non-uniform scale

N

vector

*

up

vector

Up vector of the copy*

v

vector

Velocity of the copy (for orientation and/or motion blur)*

rot

float4 (quaternion)

trans

vector

Houdini will try to find orientation attributes in the following order:

  • If an orient attribute exists, use it as the orientation.

  • Otherwise, If N exists, make the copy’s +Z axis point in that direction.

  • Otherwise, if v exists, make the copy’s +Z axis point in that direction.

  • Otherwise, if up exists, make the copy’s +Y axis point in that direction.

How Houdini calculates the transform matrix

O

Orient matrix

S

Scale matrix (scale * pscale)

L

Alignment matrix, defined by N or v and up

R

Rot matrix

T

Trans matrix (trans + P)

IF N exists AND up exists and isn't {0,0,0}:
   L = mlookat(N, 0, up)
ELSE IF N exists:
   L = dihedral({0, 0, 1}, N)
ELSE IF v exists AND up exists and isn't {0, 0, 0}:
   L = mlookat(v, 0, up)
ELSE IF v exists:
   L = dihedral({0, 0, 1}, v)

IF orient exists:
   Transform = O * R * S * T
ELSE:
   Transform = S * L * R * T