Smoothstep is a family of sigmoid-like interpolation and clamping functions commonly used in computer graphics, video game engines, and machine learning. The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument. It returns 0 if x is less than or equal to the left edge and 1 if x is greater than or equal to the right edge. Otherwise, it smoothly interpolates, using Hermite interpolation, and returns a value between 0 and 1. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. In HLSL and GLSL, smoothstep implements the S 1 ( x ) {\displaystyle \operatorname {S} _{1}(x)} , the cubic Hermite interpolation after clamping:
smoothstep ( x ) = S 1 ( x ) = { 0 , x ≤ 0 3 x 2 − 2 x 3 , 0 ≤ x ≤ 1 1 , 1 ≤ x {\displaystyle \operatorname {smoothstep} (x)=S_{1}(x)={\begin{cases}0,&x\leq 0\\3x^{2}-2x^{3},&0\leq x\leq 1\\1,&1\leq x\\\end{cases}}}
Assuming that the left edge is 0, the right edge is 1, with the transition between edges taking place where 0 ≤ x ≤ 1. A modified C/C++ example implementation provided by AMD follows.
The general form for smoothstep, again assuming the left edge is 0 and right edge is 1, is
S n ( x ) = { 0 , if x ≤ 0 x n + 1 ∑ k = 0 n ( n + k k ) ( 2 n + 1 n − k ) ( − x ) k , if 0 ≤ x ≤ 1 1 , if 1 ≤ x {\displaystyle \operatorname {S} _{n}(x)={\begin{cases}0,&{\text{if }}x\leq 0\\x^{n+1}\sum _{k=0}^{n}{\binom {n+k}{k}}{\binom {2n+1}{n-k}}(-x)^{k},&{\text{if }}0\leq x\leq 1\\1,&{\text{if }}1\leq x\\\end{cases}}}
S 0 ( x ) {\displaystyle \operatorname {S} _{0}(x)} is identical to the clamping function:
… excerpt ends here. Continue reading the full article.


