boxstep
The boxstep function is somewhere between step and smoothstep. It is the result of the convolution of a box filter with a step edge. The width of the box filter is (b - a) and the slope of the ramp is 1/width.
- boxstep(a,b,x)
- Returns 0 when (x <= a), 1 when (x >= b), a linear transition from 0 to 1 when (a < x < b), or (-1) on error (a == b).
COPY/// boxstep(a,b,x)
//
// Returns 0 when (x <= a), 1 when (x >= b), a linear transition
// from 0 to 1 when (a < x < b), or (-1) on error (a == b).
//
// a lower bound, real
// b upper bound, real
// x value, real
//
/// GMLscripts.com/license
{
var p;
if (argument0 == argument1) return (-1);
p = (argument2 - argument0) / (argument1 - argument0);
if (p <= 0) return 0;
if (p >= 1) return 1;
return p;
}
Contributors: xot
GitHub: View · Commits · Blame · Raw