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

July 26, 2019

 

 

In Houdini there are several powerful SOPs that can do amazing things, however the Copy Stamp tool is unique and allows user's 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 over complicated 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 I 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 lets put down a simple grid, scatter few points in it and connect an attribute wrangle. For this example I scattered 4 points. Before we continue, lets 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 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 points 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 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 setup properly.

 

I have tried this method to setup simple procedural crowd, 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"))

 

I am attaching some simple example files for understanding and usage of the concepts.

 

 

Population Tool - https://drive.google.com/drive/folders/1GI_F84oVu4cgx27U3R7cwOCR39YwmxCf?usp=sharing

 

Generate the cache before you begin with the Population Tool for the example to work.

 

 

 

 

 

 

 

 

 

 

 

 

 

Share on Facebook
Share on Twitter
Please reload

Featured Posts

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

August 18, 2019

1/3
Please reload

Recent Posts

November 5, 2017

Please reload

Archive
Please reload

Search By Tags
Please reload

Follow Us