fx notes

Search

Search IconIcon to open search

Wave Expressions

Last updated Jul 31, 2022 Edit Source

# Useful Periodic Functions

I recently stumbled across this phenomenal summary of wave expressions by Cameron Carson. Check it out! He wrote everything for Nuke so I decided to build a similar little library for VEX and adjust the necessary syntax / functions.


Every wrangle runs on a 10 unit long resampled line along the z-axis and includes this base code to setup the parameters:

1
2
3
4
float offset = chf("offset");
float wavelength = chf("waveLength");
float max = chf("max");
float min = chf("min");

# Random

1
@P.y = random((@P.z+offset)/wavelength) * (max-min) + min;

# Noise

1
@P.y = noise((@P.z+offset)/wavelength) * (max-min) + min;

# Sin

1
@P.y = (sin((@P.z+offset)/wavelength)+1)/2 * (max-min) + min;

# Triangle

1
@P.y = (asin(sin(2*PI*(@P.z+offset)/wavelength))/PI+0.5) * (max-min) + min;

# Square

1
@P.y = rint((sin(2*PI*(@P.z+offset)/wavelength)+1)/2) * (max-min) + min;

# Sawtooth

1
@P.y = ((@P.z+offset) % wavelength)/wavelength * (max-min) + min;

# Sawtooth Parabolic

1
@P.y = sin((PI*(@P.z+offset)/(2*wavelength)) % (PI/2)) * (max-min) + min;

# Sawtooth Parabolic Reversed

1
@P.y = cos((PI*(@P.z+offset)/(2*wavelength)) % (PI/2)) * (max-min) + min;

# Sawtooth Exponential

1
@P.y = (exp(2*PI*((@P.z+offset) % wavelength)/wavelength)-1)/exp(2*PI) * (max-min) + min;

# Sawtooth Exponential Reversed

1
@P.y = (exp(2*PI*(1-(((@P.z+offset) % wavelength)/wavelength)))-1)/exp(2*PI) * (max-min) + min;

# Bounce

1
@P.y = abs(sin(PI*(@P.z + offset)/wavelength))* (max-min) + min;

# Blip

1
2
3
4
5
6
7
8
9
float bliplength = chf("bliplength");
float value = ((@P.z+(offset+wavelength)) % (wavelength+bliplength)/(wavelength)) * (wavelength/bliplength) - (wavelength/bliplength);

if(value > 0)
{
    value = 1;
}

@P.y = fit01(value, min, max);

sources / further reading:


Interactive Graph