Last active
September 25, 2020 17:51
-
-
Save arifd/22757d4f0c46d9b77f3ba40a813f81b6 to your computer and use it in GitHub Desktop.
This file contains 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
// 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