Houdini Resources

Updated on Sept 1  2022


copyright © Deborah R. Fowler

Houdini Instancing

Deborah R. Fowler



Updated: Oct 27   2013 
Updated: Oct 2  2015

note this was written using version 12.1.77 - for example files see my Tips and Tricks page

Also please see new Packed Primitives in Houdini.

Instancing(Highlights):

This page is based on the excellent tutorial by Scott Keating (Oct 31, 2012) and is designed as a supplemental handout for 350/428 to highlight some of the not to be missed details – this example includes a very simple vopsop. This is by no means a replacement for this tutorial, and you should review this video and treat this document as reminder notes. In addition, you should review the instance attribute files on the Tips and Tricks page as well.

NOTE: on linux, instances will display by default, on windows they will not. You likely will want to reduce or turn this off.

Instancing is very similar to the copy sop, however it is very powerful for complex scenes as it saves on display and render resources (usually in a complex scene we don’t have the m/c memory to see all). Hit d in the scene view to bring up the display options and under the geometry tab you will see a tickbox for point instancing as well as a percent.

Instancing goes beyond what a copy sop can handle.

To use instancing you need points and objects to put on those points. We can control the objects by associating attributes with the points.
 
To begin
Next


Now reference the object in the instance node under the instance tab:

Note that Fast point instancing is recommended for H12.


You will now have a box at every point. These are not copies but instances.
Suppose now that you want to manipuate the instances so that each has different characteristics much the same way you used the copy number and copy stamping to manipulate copies. In this case we need to associate attributes with the points.

If you go to "help" and search "copying and instancing", click on the Copying and instancing page and you will see at the bottom Guru level. This has a list of all the copying and instancing point attributes.

Inside the instanceTemplate, add a point sop and select Add Scale under the particle tab delete the channel and type in rand($PT) into the field. You could also type in fit01(rand($PT),1,2) to make the sizes range from 1 to 2. Instead of a point sop you could add an attribute node and write the values into pscale.

Creating a simple vopsop

Another method that is more versatile and introduces vopsop is to create a vopsop. Vops are very handy. We will concentrate on vops in 428, but they are also a handy thing to know in 350. Essentially vops manipulate data. Your vop network looks similar to your sop network in some ways. Replace the point node with a vopsop node.

    Dive into the vopsop you have put down.
    Hit tab and type random.
    Wire the point number from global1 into random1.
    Create an "add attribute" node.
    This has equivalent functionality to the point sop with rand($PT).
    Create a fit node as well - "fit range" - and
    set the destination min to 1 and max to 2
    This is equivalent to the point sop with fit01(rand($PT,1,2)


This may seem like more work, however there are many cases where it can be an invaluable shortcut.

In the video, Scott Keating also adds parameters to add more control such as a multiplier for the random number to change the "seed" and parameters for the min/max values. To access existing parameters, left mouse click the gear symbol next to the parameter and select "Promote Parameter". You can either expose the input, or left mouse click again and select "Jump to Input", or click on the circles.

Manipulating rotation

    One way to manipulate the direction would be to manipulate the normals. Instancing will align to the normal.
    We could add a point sop again, and this time under the standard tab, add normal and set the x, z values to rand expressions.

    Alternatively, we could add an attribute using an "AttribCreate" node (as pictured left)
    Set the name to N,
    type to Vector and
    values to
    rand($PT * $TX) * 2 -1, $NY and rand($PT) * 2 - 1

    This method works fine if you are on a planer surface, but what if you are instancing on a sphere? What your really want is to associate a transformation matrix with your point. This is a case for vopsops.

The attribute to do this is orient.
This property uses quarterians. The vopsop is described below:







    Here is the vopsop as described in the tutorial. The attribute that is added is orient. rotateSeed, multiply, random and fit are analogous to the pscale method described above.
    However, the node "rotate" has a transformation matrix, an angle (expected in radians) and an axis of rotation (expected to be normalized - ie. length of 1).
    Input to the rotate node:




The materials can also be manipulated using the same techniques as for pscale.
Various methods exist for creating differing instance objects. There are some examples in the Tips and Tricks section.
The one shown in the video is now my favorite. It uses a string variable with the number generated randomly and converted to a string to select between objects.
The key is to know that the attribute name that instancing understands is "instance". In the video, Scott Keating creates another attribute in the vopsop to create a number.

Alternatively, you could use the expression you see below. The important thing is to make sure you call the attribute instance, specify the path, and remove the reference in the instance container.



Further, you can instead use a pointer to a file from disk (attribute "instancefile") and be sure to reference it relative to the hip file ($HIP/...).


Finally the instances are assigned to an input image, again extracting information with a vopsop.