NAME

smoothstep - interpolate smoothly between two input values based on a third

SYNOPSIS

  float  smoothstep(float  a, float  b, float  x);
  float1 smoothstep(float1 a, float1 b, float1 x);
  float2 smoothstep(float2 a, float2 b, float2 x);
  float3 smoothstep(float3 a, float3 b, float3 x);
  float4 smoothstep(float4 a, float4 b, float4 x);
 
  half   smoothstep(half  a, half  b, half  x);
  half1  smoothstep(half1 a, half1 b, half1 x);
  half2  smoothstep(half2 a, half2 b, half2 x);
  half3  smoothstep(half3 a, half3 b, half3 x);
  half4  smoothstep(half4 a, half4 b, half4 x);
 
  fixed  smoothstep(fixed  a, fixed  b, fixed  x);
  fixed1 smoothstep(fixed1 a, fixed1 b, fixed1 x);
  fixed2 smoothstep(fixed2 a, fixed2 b, fixed2 x);
  fixed3 smoothstep(fixed3 a, fixed3 b, fixed3 x);
  fixed4 smoothstep(fixed4 a, fixed4 b, fixed4 x);

PARAMETERS

a

Scalar or vector minimum reference value(s).

b

Scalar or vector minimum reference value(s).

x

Scalar or vector.

DESCRIPTION

Interpolates smoothly from 0 to 1 based on x compared to a and b.

1) Returns 0 if > or a > b>>

1) Returns 1 if > or b > a>>

3) Returns a value in the range [0,1] for the domain [a,b].

The slope of smoothstep(a,b,a) and smoothstep(a,b,b) is zero.

For vectors, the returned vector contains the smooth interpolation of each element of the vector x.

REFERENCE IMPLEMENTATION

smoothstep for float scalars could be implemented this way:

  float smoothstep(float a, float b, float x)
  {
      float t = saturate((x - a)/(b - a));
      return t*t*(3.0 - (2.0*t));
  }

PROFILE SUPPORT

smoothstep is supported in all profiles except fp20.

SEE ALSO

clamp, saturate, step