此 API 是实验性的
其行为可能在 p5.js 的未来版本中发生变化。
A shader function that performs smooth Hermite interpolation between 0.0 and 1.0.
This function is equivalent to the GLSL built-in smoothstep(edge0, edge1, x) and is available inside p5.strands shader callbacks. It is commonly used to create soft transitions, smooth edges, fades, and anti-aliased effects.
Smoothstep is useful when a threshold or cutoff is needed, but with a gradual transition instead of a hard edge.
- Returns
0.0whenxis less than or equal toedge0 - Returns
1.0whenxis greater than or equal toedge1 - Smoothly interpolates between
0.0and1.0whenxis between them
示例
语法
smoothstep(edge0, edge1, x)
参数
edge0
Number: Lower edge of the transition
edge1
Number: Upper edge of the transition
x
Number: Input value to interpolate
返回值
Number: A value between
0.0 and 1.0Notice any errors or typos? Please let us know. Please feel free to edit src/strands/p5.strands.js and open a pull request!