Inline Code VOP - ch() expressions

   769   5   1
User Avatar
Member
16 posts
Joined: 6月 2018
Offline
Hello everyone!

Is it possible to use ch() expressions in any capacity inside VOPs? Ideally, inside an `Inline Code VOP` node, instead of creating a bunch of inputs. I tried multiple approaches in both nodes, but had no luck.

I found some mentions in the documentation for the Snippet VOP node but it didn't work or i missing something:
You can use the VEX function ch to evaluate parameters. The path is relative to this node (ch("parm") will evaluate the parameter parm on this node). This evaluation will be done at the current time.


Thanks!
Senior Technical Artist at Cloud Imperium Games
User Avatar
Member
4702 posts
Joined: 2月 2012
Offline
Hi,

Inline VOP is older. Is there a reason you don't want to use the Snippet VOP?

You can do it like this but anytime you change the parameter, the performance will tank so it's not recommended to use that workflow:





This will be much faster when you are changing the parameters:

Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
16 posts
Joined: 6月 2018
Offline
Hi Animatrix,

Thank you for your quick response! I didn’t realize Inline is the older option. Are there any downsides besides the use of ch() expressions? The documentation doesn’t seem to go into much detail about this.

I use Inline for its convenience with input and output management. It allows me to have one input, "P," and multiple outputs, which feels more intuitive. However, as I mentioned, many aspects aren’t entirely clear, and I’m wondering if there is an ideal use case for each approach.

I have another question: Isn't a wrangle essentially a VOP with a snippet inside (well before H19 anyway)? How does it manage to propagate ch() with better performance? Also, did the wrangle HDA change (Attribute Wrangle Core)? Was that related?

Haha, here we go... down the rabbit hole!

Thanks!
Senior Technical Artist at Cloud Imperium Games
User Avatar
Member
4702 posts
Joined: 2月 2012
Offline
Personally I often prefer Attrib Wrangle SOP, but if I need to build a VOP network then I will use Bind if I don't need parameters. If I need parameters, then I always use parameters.

The speed differences between using ch directly in your Inline Code VOP or Snippet VOP comes from parameter binding and changing function signatures.

If you inspect the code generated by using ch directly, you get this code:

VOP_SNIPPET_snippet1(vector p; const float _bound_Time)
{
    vector center = 0;
    float dist = length ( p - center );
    
    float frequency = ch("freq");
    float amplitude = 0.1;
    float speed = 2.0;
    
    p.y = sin ( dist * frequency - _bound_Time * speed ) * amplitude;
    
}

So anything the frequency value changes, it recompiles the VEX code, that's why it's much slower.

Using a parameter VOP instead produces this code:

VOP_SNIPPET_snippet1(vector p; float freq; const float _bound_freq; const float _bound_Time)
{
    vector center = 0;
    float dist = length ( p - center );
    
    float frequency = _bound_freq;
    float amplitude = 0.1;
    float speed = 2.0;
    
    p.y = sin ( dist * frequency - _bound_Time * speed ) * amplitude;
    
}

As you can see in this code, frequency value is passed to the function so there is no need to recompile the code. If just calls the same function with a different value.

float freq is used to output the value.

Attribute Wrangle Core is exactly an Attribute VOP, except it doesn't have a VOP network inside of it. This means on loading networks from disk it can be faster as none of the VOP specific rules have to be applied. It will have no effect on actual execution speed.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
16 posts
Joined: 6月 2018
Offline
Thank you so much! This explanation was incredibly helpful.

By the way, I bought your tutorial a while ago, and it was excellent! I really appreciated the in-depth focus on optimization. Just out of curiosity, do you have any plans for a Volume 2?
Senior Technical Artist at Cloud Imperium Games
User Avatar
Member
4702 posts
Joined: 2月 2012
Offline
Thanks a lot, appreciate your support! Your name definitely rings a bell!

Pragmatic VEX: Volume 2 is currently in the editing stage, with about half of the work completed, with a strong mix of unique and advanced topics, all designed to be highly practical for production workflows.

The release is planned for early next year.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
  • Quick Links