-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
- step
step (a, x)
{
if (x < a)
{
return 0;
}
else
{
return 1;
}
}
当 x < a时,返回0;反正返回1;
- lerp
lerp(a, b, w)
{
return a + w*(b-a)
}
当 w = 0 时,返回a,当 w = 1 时,返回b;
否则返回对 a 和 b 的差值,w 越接近0,返回结果越接近a,w越接近1,返回结果🈷️接近1,通常用来计算一些渐变量。
- smoothstep
float smoothstep(float a, float b, float x)
{
x = clamp((x - a) / (b- a), 0.0, 1.0);
return x * x * (3 - 2 * x);
}
smoothstep可以用来生成0到1的平滑过渡值,它也叫平滑阶梯函数。
例子参考:
https://www.jianshu.com/p/53fe928a0fb6
Metadata
Metadata
Assignees
Labels
No labels