Skip to content

Instantly share code, notes, and snippets.

View Zi7ar21's full-sized avatar
🧓
Writing C/C++

Jacob Bingham Zi7ar21

🧓
Writing C/C++
View GitHub Profile
@Zi7ar21
Zi7ar21 / notsosmoothstep.h
Created May 19, 2023 18:36
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;
}