image.png
归纳上式:
float smoothstep(float edge0, float edge1, float x) {
// Scale, bias and saturate x to 0..1 range
// 还记得么?在remap算法中接触过
x = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
// Evaluate polynomial
return x * x * (3 - 2 * x);
}
float clamp(float x, float lowerlimit, float upperlimit) {
if (x < lowerlimit)
x = lowerlimit;
if (x > upperlimit)
x = upperlimit;
return x;
}
根据上式,我们找些数字代入,假设e0=-2,e1=3:
y = (x-(-2))/(3-(-2)) ; -2<=x <=3,x>3 x=1,x<-2 x=0
且result = yy(3-2*y)
x还是取两个特殊值,分别为-2,3
当x=-2,y=0
当x=3,y=1
此时可以作简陋图如下:
image.png
如果e0=3,e1=-2,
则x=-2时,y=1;
x=3,y=0
正好与上图相反
image.png
image.png












网友评论