## clamp 获取x和minval之间较大的值,然后再结果值与最后的最大值比较取最小值 ``` float clamp(float x, float minVal, float maxVal) vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal) vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal) vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal) vec2 clamp(vec2 x, float minVal, float maxVal) vec3 clamp(vec3 x, float minVal, float maxVal) vec4 clamp(vec4 x, float minVal, float maxVal) ex float result = clamp(5,3,100); //result = 5 ``` ## smoothstep ``` float smoothstep(float edge0, float edge1, float x) vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x) vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x) vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x) vec2 smoothstep(float edge0, float edge1, vec2 x) vec3 smoothstep(float edge0, float edge1, vec3 x) vec4 smoothstep(float edge0, float edge1, vec4 x) //平滑阶梯函数:smoothstep可以用来生成0到1的平滑过渡值 //函数实现 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); } ``` ijk播放器参数设置 Debian9安装unas4.0笔记
No Leanote account? Sign up now.