Skip to content

Instantly share code, notes, and snippets.

@eliemichel
Last active July 16, 2018 13:07
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 eliemichel/1ca8bc41533d1cdcd582e19d9e6f6853 to your computer and use it in GitHub Desktop.
Save eliemichel/1ca8bc41533d1cdcd582e19d9e6f6853 to your computer and use it in GitHub Desktop.
Fade out offset
// Fade in
{
float x0 = ch("../PARAM/start_crossfade_frame");
float x1 = ch("../PARAM/end_crossfade_frame");
float a1 = 0.01;
float a0 = a1 / (2 * (x1 - x0));
float b1 = a0 * (x1 - x0) * (x1 - x0) - a1 * x1;
return if($FF < x0, 0, if($FF < x1, a0 * ($FF - x0) * ($FF - x0), a1 * $FF + b1));
}
// Fade out
{
float x0 = ch("../PARAM/start_crossfade_frame");
float x1 = ch("../PARAM/end_crossfade_frame");
float a0 = 0.1;
float a1 = - a0 / (2 * (x1 - x0));
float b1 = - 2.0 * a1 * x1;
float c1 = ((a0 - b1) - a1 * x0) * x0;
float b2 = (a1 * x1 + b1) * x1 + c1;
return if($FF < x1, if($FF < x0, a0 * $FF, (a1 * $FF + b1) * $FF + c1), b2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment