Cinema 4D User Data

Parameter References in VEX Snippets

Hey! What’s that? < incessantly pressing the button >
Oh well… It does nothing.

Since it was nagging me, I looked in the help files for the POP Wrangle but I couldn’t find any mention of the button. The tooltip was not helping me and in hindsight, I’m embarrassed to admit it was sort of obvious. I deserve cat pee on the sofa. Anyways, after thorough research1 I figured out what it actually does.

 

What's that?
What’s that?

Spare Parameters

If you’re learning Houdini, you probably already came across the nifty bit about being able to add your own custom parameters to a node’s user interface. You then access those custom parameter values with expressions. If you have used Cinema 4D, then think User Data and linking the stuff up with Xpresso, Python, etc.

 

Cinema 4D User Data
Cinema 4D User Data

 

It’s a bit of a process in Houdini. You have to open the Parameter Interface for the node and create parameter types, set the name and label at the minimum, then link them with other parameters using the channel functions. Not a big deal but if you don’t want to miss that episode of The Fall Guy on TV, time is of the essence.

When you’re in a POP Wrangle or Attribute Wrangle for example, you may do the same thing to change the value of a multiplier. As an example, I have this glorious sphere that is emitting particles and some added force for award winning style points.

 

refChannel05

Let’s say we want to add noise to the velocity of the particles and we pass in the particle’s age as an argument. Then multiple it by some value to speed or slow them down. I’m also coloring the particles based on velocity. Remember velocity and color are vectors, so this is why I am able to assign @v to @Cd. It’s just an arbitrary example to demonstrate.

So I drop down my good old Wrangle node and type in the VEX expression:

float mult_value = 2;
@v += noise(@nage) & mult_value;
@Cd = @v;

refChannel06

Easy enough. However, wouldn’t it be better to be able to keyframe or have interactive control of the mult_value with say a slider control instead of it being a hard coded value? Of course!

This is where that little thingamajig comes into the picture. Instead of going through the whole “Open the Parameter Interface, blah, blah, blah…”, all you have to do is click on that image of a tube with a hotdog coming out of it.

But wait! It won’t work just yet. You have to do one last step. We know we have to use our channel functions. In this case, we will be using the chf function since the value is a float. So we refactor the code like the following:

float mult_value = chf(”multiplier”);
@v += noise(@nage) * mult_value;
@Cd = @v;

refChannel07

Notice I passed the chf function an arbitrary string. You would of course name it in a way to indicate what the value is actually doing. Now you can go ahead and click on the button and like magic, the spare parameter will be created underneath the VEX editor window or whatever that thing is called. What fun!

 

refChannel09

Also, I could have eliminated the float variable and just had one line of code but this way it’s cleaner. You’re essentially doing the reverse. You write your function first then the parameter is created. In contrast to creating the parameter first then writing the function to link the parameters together. You can always open up the Parameter Interface and reorder your parameters.

 

refChannel08

There you have it! Fall Guy time!


 

  1. I actually come across it by mistake.
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.