Skip to content

Instantly share code, notes, and snippets.

@Zi7ar21
Created May 19, 2023 18:36
Show Gist options
  • Save Zi7ar21/d3dab18f2e86d117592a8c9973516505 to your computer and use it in GitHub Desktop.
Save Zi7ar21/d3dab18f2e86d117592a8c9973516505 to your computer and use it in GitHub Desktop.
Smoothstep but less continuous
float notsosmoothstep(float x, float edge0, float edge1) {
x = (x - edge0) / (edge1 - edge0); // [edge0, edge1] -> [0, 1]
x = x < 0.0 ? 0.0 : x; // max(x, 0)
x = x > 1.0 ? 1.0 : x; // min(x, 1)
x -= 0.5;
return 2.0*(-x*abs(x)+x)-0.5;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment