Skip to content

Instantly share code, notes, and snippets.

@arifd
Last active September 25, 2020 17:51
Show Gist options
  • Save arifd/22757d4f0c46d9b77f3ba40a813f81b6 to your computer and use it in GitHub Desktop.
Save arifd/22757d4f0c46d9b77f3ba40a813f81b6 to your computer and use it in GitHub Desktop.
// cheaper smoothstep
// https://forum.unity.com/threads/how-expensive-is-smooth-step-in-shaders-for-mobile.501809/
float cheapstep(float a, float b, float x) {
// remap the value
float remap = x * (1.0 / (b - a)) - (a / (b - a));
// clamp it to 0 and 1, as smoothstep would
return clamp(0., 1., remap);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment