Jump to content

Vex - smooth interpolation of random values


art3mis

Recommended Posts

Trying to learn VEX.

Using the following simple formula in a wrangle to create random green color values on geometry
 

@Cd = 0;

@Cd.g = rand(@ptnum);

 

Lets say I want different random values at frame 120 and I want the values to smoothly interpolate between frame 1 and 120.

How would I do this?

 

Link to comment
Share on other sites

Unless I'm misunderstanding your question, you could also do this. It will interpolate between two green values over the frame range 1-120

// create first random value

float value1 = rand(@ptnum);

// create second random value

float value2 = rand(@ptnum + 325);

// interpolate between thoose two values over the frame range 

float current_value = fit(@Frame, 1, 120, value1, value2);

// set that to the current colour

@Cd = set(0, current_value, 0);

Link to comment
Share on other sites

Szymon, thanks. I wasn't aware of this! Wow, very powerful

 

Thanks Richard. Got it. So essentially using frame value to drive interpolation. How might you use time value to accomplish the same thing?

Link to comment
Share on other sites

@Time is the current time in seconds. So @Frame = @Time * 24. If your frame rate is set to 24frames per second.

Therefore they are pretty interchangeable, and accomplish the same thing. Personally I always use @Frame and would only use @Time for sub frame stuff, which I never really need.

 

Link to comment
Share on other sites

  • 3 weeks later...

Btw as you have mentioned "smooth", this VEX function came to my mind:
http://www.sidefx.com/docs/houdini/vex/functions/smooth

As it says:

- smooth (easin and easeout) interpolation is computed
- If a rolloff is specified, the inflection point of the blend will be shifted.

Once I wanted just ease-in (no ease-out), Python has it (http://www.sidefx.com/docs/houdini/hom/hou/ease) but VEX probably doesn't. I have quite solved it with VEX and that biased rolloff.

Edited by ikoon
edit: btw Jim, I think that you will like chops, try Matt Estela's intro to chops
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...