top of page

Using VEX to Art Direct your Copy Stamp (Part 1)



In Houdini there are several powerful SOPs that can do amazing things, however, the Copy Stamp tool is unique and allows users to apply a multitude of techniques and achieve several FX, Models etc. Many users use the copy stamp SOP to distribute geometry or volumes randomly and stop there but I thought to myself, why can't we take this amazing tool and use it to specifically art direct values of each stamp? In the past I have overcomplicated things and looked at several methods to control values for an attribute on each point, in doing so I have landed up watching several tutorials which did not answer my question.

One day I sat down and found that I can achieve this by using a VEX snippet of only 2 lines and the parameter interface.


In a new piece of Geometry let's put down a simple grid, scatter a few points in it and connect an attribute wrangle. For this example, I scattered 4 points. Before we continue, let's take a look at the concept of what we are going to do. If I type the following code in the wrangle "@val = ch("value")" and press "create a spare parameter for each individual ch()".

I would have created a float parameter that I can use to assign the attribute "val" a certain value, the problem in doing so is that I have declared the same value for each point.

I want to individually declare values for each point and control it like so:

point 0 = 1
point 1 = 3
point 2 = 7
point 3 = 5

To do so I can use the point numbers to my advantage by creating sliders that contain the same number as the point and therefore use them as a direct reference.

However, in cases where you have a lot of points, you cannot create 100s of parameters and rename each. In this case, we can use Houdini Parameter Interface to our advantage. Under the edit parameter interface setting there is a Tab called "By Type", select the Folder and add it to your interface. Change the "Folder Type" to "Multiparm Block (list)" and add a float inside it. Now when you accept, you will see that the folder has a "+" sign, on pressing it creates multiple sliders. The Multiparm creates an instance using a "#" if you look back at the float parameter on the Edit Parameter Interface, you will see a "#" was added to it, you can add the "#" to the name as well for convenience. Do not forget to change the "First Instance" on the Multiparm Block to "0" since we want to reference our point numbers. For this example, I am calling my float parameter "value#"

Now we have got the parameters with the instance number but we still need to connect it to the point number.

To do so I typed the following VEX code:

string pt = itoa(@ptnum);
@val = ch("value" + pt);

In this code, I have simply stitched together two strings and used that in the ch() name to reference the respective parameter. Since @ptnum is an integer, I converted it to a string using itoa and stored it away in a string. All I had to do then was simply stitch the name of the float and pt.


Now that I can control each point all I have to do is call the attribute in the copy stamp SOP and use the stamp expression.


This method works with integers, floats, strings, vector and even vector4 if set up properly.

I have tried this method to set up simple procedural crowds, art directing instances and even control my WEDGES. Most methods like Wedge and Copy Stamping are used for random values but this method gives users an option to control each iteration on demand.

To do the same thing with wedges all you have to do is create the same folder and parameter setup on a null and wherever you want to override parameters you can use this:

ch("PATH_TO_THEPARAMTER(NAME)" + ch("PATH_TO_THE_WEDGENUM_PARM"))

example:

ch("../Overrides/gravity" + ch("../Overrides/wedgenum"))



Featured Posts
Recent Posts
Comments

Share Your ThoughtsBe the first to write a comment.
Archive
Search By Tags
Follow Us
  • LinkedIn
  • Youtube
  • Vimeo
  • Instagram
bottom of page