Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

art3mis

Vex - smooth interpolation of random values

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?

 

Share this post


Link to post
Share on other sites

This is what noise functions were designed for: http://www.sidefx.com/docs/houdini/vex/random

They are also available in VOPs (look in Tab menu under "Patterns" category). Noise function smoothly interpolates both in space domain and time domain (pseudo)random values.   

Share this post


Link to post
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);

Share this post


Link to post
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?

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now