Skip to content

Instantly share code, notes, and snippets.

@taikomatsu
Last active January 22, 2019 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taikomatsu/f11b078333e40a77d780bed2c5522909 to your computer and use it in GitHub Desktop.
Save taikomatsu/f11b078333e40a77d780bed2c5522909 to your computer and use it in GitHub Desktop.
bias & gain for VEX
float bias(float b; float x) {
return pow(x, log(b)/log(0.5));
}
float gain(float g; float x) {
if (x<0.5)
return bias(1-g, 2*x)/2;
else
return 1-bias(1-g, 2-2*x)/2;
}
// usage example
float x = v@P.x;
//v@P.y = bias(0.8, x);
//v@P.y = bias(0.2, x);
//v@P.y = gain(0.8, x);
v@P.y = gain(0.3 , x);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment