Cg Toolkit Cg 3.1 Toolkit Documentation
Cg / Standard Library / smoothstep

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 x < a < b or x > a > b
1) Returns 1 if x < b < a or x > 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


Cg Toolkit | Cg Toolkit | Download | Release Archive | Profiles | Reference | Books | Discussions |


Cg Standard Library

abs
acos
all
any
asin
atan2
atan
bitCount
bitfieldExtract
bitfieldInsert
bitfieldReverse
ceil
clamp
clip
cosh
cos
cross
ddx
ddy
degrees
determinant
distance
dot
exp2
exp
faceforward
findLSB
findMSB
floatToIntBits
floatToRawIntBits
floor
fmod
frac
frexp
fwidth
intBitsToFloat
inverse
isfinite
isinf
isnan
ldexp
length
lerp
lit
log10
log2
log
max
min
modf
mul
normalize
pack
pow
radians
reflect
refract
round
rsqrt
saturate
sign
sincos
sinh
sin
smoothstep
sqrt
step
tanh
tan
tex1DARRAYbias
tex1DARRAYcmpbias
tex1DARRAYcmplod
tex1DARRAYfetch
tex1DARRAYlod
tex1DARRAY
tex1DARRAYproj
tex1DARRAYsize
tex1Dbias
tex1Dcmpbias
tex1Dcmplod
tex1Dfetch
tex1Dlod
tex1D
tex1Dproj
tex1Dsize
tex2DARRAYbias
tex2DARRAYfetch
tex2DARRAYlod
tex2DARRAY
tex2DARRAYproj
tex2DARRAYsize
tex2Dbias
tex2Dcmpbias
tex2Dcmplod
tex2Dfetch
tex2Dlod
tex2DMSARRAYfetch
tex2DMSARRAYsize
tex2DMSfetch
tex2DMSsize
tex2D
tex2Dproj
tex2Dsize
tex3Dbias
tex3Dfetch
tex3Dlod
tex3D
tex3Dproj
tex3Dsize
texBUF
texBUFsize
texCUBEARRAYbias
texCUBEARRAYlod
texCUBEARRAY
texCUBEARRAYsize
texCUBEbias
texCUBElod
texCUBE
texCUBEproj
texCUBEsize
texRBUF
texRBUFsize
texRECTbias
texRECTfetch
texRECTlod
texRECT
texRECTproj
texRECTsize
transpose
trunc
unpack