stemp
step(t,limit)
t<limit
,返回0t>limit
,返回1
smoothstep
smoothstep(limitA,limitB,t)
limitA
,limitB
设置两个边界,计算时会与t
做对比- 如果
limitA<limitB
说明这个曲线是上升的,小于最小极限为0,大于最大极限为1,中间插值 - 如果
limitA>limitB
说明这个曲线是下降的,小于最小极限为1,大于最大极限为0,中间插值
函数内部
float smoothstep(float t1, float t2, float x) {
// Scale, bias and saturate x to 0..1 range
// 还记得么?在remap算法中接触过
x = clamp((x - t1) / (t2 - t1), 0.0, 1.0);
// Evaluate polynomial
return x * x * (3 - 2 * x);
}
评论