Light | Dark

smoothstep

Name

smoothstep — perform Hermite interpolation between two values

Declaration

genType smoothstep( genType edge0,
genType edge1,
genType x);
genType smoothstep( float edge0,
float edge1,
genType x);

Parameters

edge0

Specifies the value of the lower edge of the Hermite function.

edge1

Specifies the value of the upper edge of the Hermite function.

x

Specifies the source value for interpolation.

Description

smoothstep performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1. This is useful in cases where a threshold function with a smooth transition is desired. smoothstep is equivalent to:

    genType t;  /* Or genDType t; */
    t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
    return t * t * (3.0 - 2.0 * t);

smoothstep returns 0.0 if xedge0 and 1.0 if xedge1.

Results are undefined if edge0edge1.

Version Support

OpenGL ES Shading Language Version
Function Name 1.00 3.00 3.10
smoothstep (genType)

See Also

mix, step

Think you can improve this page? Edit this page on GitHub.