Last active
February 2, 2022 10:09
-
-
Save memononen/df1728511aed9e410d871bbff0a58c83 to your computer and use it in GitHub Desktop.
bias gain inflection point
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float evalCurve(float x, float tx, float ty, float sa, float sb) | |
{ | |
const float EPS = 1e-6f; | |
if (x < tx) { | |
return (ty * x) / (x + sa * (tx - x) + EPS); | |
} else { | |
return ((1-ty) * (x-1)) / ((1-x) - sb * (tx - x) + EPS) + 1.0f; | |
} | |
} | |
float tx = pts[0].x; // Inflection point | |
float ty = pts[0].y; | |
float slope = (pts[0].y - pts[1].y) / (pts[0].x - pts[1].x); // Second control point controls slope | |
float slopea = slope * ((tx-0)/(ty-0)); | |
float slopeb = slope * ((1-tx)/(1-ty)); | |
float y = evalCurve(x, tx, ty, slopea, slopeb); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment