Pages Navigation Menu

Technical Artist

Looping Techniques in Houdini, Part Two

This is the second part of a two-part series. Part one can be found here.

With the advent of the wrangle nodes in Houdini 12.5 and greater, it is time to revisit the looping techniques discussion. We now have two new options for looping through points and primitives in Houdini: point wrangle and attribute wrangle.

The point and attribute wrangle nodes are very convenient for interjecting snippets of VEX code in your node networks for some extremely fast and flexible operations. Further, we will see that the attribute wrangle node can actually be used to iterate over primitives as well as points, giving us a new alternative for primitive looping as well.

Points

To highlight speed differences, I have decided to scatter 5 million instead of 50,000 points for these speed tests. As in Part I, I simply scatter the points on a grid, sort them by proximity to the origin, and move them upwards with the following line of VEX:

@P.y  += @ptnum;

You can see the speed results below. I have included the VOPSOP and Point SOP techniques from Part I for comparison. If you’re a fan of VEX, you’ll be pleased by the results. I will discuss in more detail in the Conclusion section.

loopingTechniques_v2

Primitives

With the AttribWrangle SOP, we have the ability to set the “Run Over” parameter to primitives instead of the default points. This gives us a great new method for looping primitives that we didn’t have before. The VEX:

@P.y += @primnum;

In the results below I have included the Point SOP method from Part I, which was the fastest of the techniques shown. You’ll see what a great new addition we have with the AttribWrangle:

loopingTechniques_prims_v2

 

Conclusion

You can see that for looping points, the Point Wrangle is extremely fast – roughly equivalent to the VOPSOP (which makes sense, since VOPSOPs just bake down to VEX anyway). The wrangles and VOPSOP really just blow away the Point SOP for huge point sets. There’s an interesting blip with the AttribWrangle, which ran in in about half the time that it took the Point Wrangle. However, we’re talking about 0.016s difference, which in reality I would chalk up to actual overhead to spin up the node’s computation. In other words, I don’t think that the AttribWrangle is twice as fast as the Point Wrangle – I cranked up some of the trials to 30 million points and the AttribWrangle was still coming in just slightly ahead of the Point Wrangle. The great news is that the new wrangle nodes provide an extremely fast venue for executing VEX code, much like a VOPSOP, but with some serious extra flexibility such as creating and removing points. Further, some operations are much more natural to write in a VEX snippet than in a VOP network.

As for looping primitives, we have a great new technique! The AttribWrangle can loop over a set of primitives in a fraction of the time that it takes the Point SOP. This is really great news, as we now have a simple way for iterating over large primitive sets in almost no time at all. I highly recommend taking the time to explore the AttribWrangle SOP, as it has some really interesting capabilities beyond the Point Wrangle.

 

2 Comments

  1. Wow, thanks Kevin! it´s very nice!

    As i new to Houdini (only 5 months) can you share the HIP file? I wish to learn from your scene the various techniques.

    Thanks again, you was fast! ;)

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">