Using the op Operator

Using the Op Operator

I’m sure you’ve seen the op operator while on your Houdini tutorial journeys or rummaging through .hip files. It usually goes something like this:

op:/path/to/node

Cryptic stuff. I know, I was like ”WTF is that?” when I first saw it. Turns out it’s rather handy. What is cool about the op operator is that it allows you to grab live data from another node elsewhere in your scene. Let’s try to break it down with an example of sorts.

Beer with A Straw

Imagine you’re on a beach and there are several bars around. One bar in particular changes its selection of premium craft beer every hour. You definitely want to take advantage of that! However, getting up and walking over to the bar every hour is a real drag.

Now image if you had a really long straw that stretched all the way over to the bar right to the beer tap. The advantage of this is that as the beer gets updated with a new selection, you have instant access to that new brew without ever having to leave your spot on the sand.

The op operator works in similar fashion. The popular example is to reference an image from a COPS network but you can use it in any parameter field which expects a file name. Essentially, you’re grabbing live data from nodes in the scene hierarchy instead of from a file. This will work as long as the data being fed in is the type of data the parameter expects.

One important point to be aware of is that the path to the node must be an absolute path starting from the root path. No ../../ nonsense. However, Houdini provides the opfullpath function which returns the full path of a node. In order to use it, make sure you enclose the function within back ticks so it gets evaluated properly like so:

op: `opfullpath(“../../your_node_with_data”)`

Grabbing Live Data

In the simple example below, I have a shader ball that has been assigned a Principled Shader. I’m using a color map for the base color which references a Ramp operator in a COPS network. Again, notice the tick marks to enclose the opfullpath function. I can update my Ramp colors and my shader map will update automatically. Of course, this can apply to many other things.

op operator
Op operator being used for color map

 

Ramp Operator
Ramp Operator being referenced

 

Using Op in a Point Function

Another place you can use the op operator is within a point() function. The point function has a couple of signatures.

point(int opinput, string attribute_name, int pointnumber)
point(string geometry, string attribute_name, int pointnumber)

The second signature for the point() function allows you to pass in a string which would be the path to the geometry object. Here I’m just grabbing the color of a point on one geometry and applying it to another. Convoluted? Yes. But still really neat! Notice I need to surround the whole op operation within quotes since the point() function is expecting a string.

Op inside a point function
Op inside a point function

 

Grabbing data with the Op operator
Grabbing data with the Op operator
Share:
990adjustments

990adjustments

I am a motion designer & developer based out of South Florida. When not designing or animating pixels, I wrangle some code. If all else fails, I watch Twilight Zone, I Love Lucy, or Three's Company reruns.