'smoothstep' : 未找到匹配的重载函数

'smoothstep' : no matching overloaded function found

我正在 GLSL 上执行 Book of Shaders tutorial 并尝试使用 smoothstep 函数,但出现此错误。当我将 step 更改为下面的 smoothstep 函数时,您可以看到它发生了。

// Author @patriciogv - 2015
// http://patriciogonzalezvivo.com

#ifdef GL_ES
precision mediump float;
#endif

uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;

void main(){
    vec2 st = gl_FragCoord.xy/u_resolution.xy;
    vec3 color = vec3(0.0);

    // bottom-left
    vec2 bl = smoothstep(vec2(0.1),st); 
    float pct = bl.x * bl.y;

    // top-right 
    // vec2 tr = step(vec2(0.1),1.0-st);
    // pct *= tr.x * tr.y;

    color = vec3(pct);

    gl_FragColor = vec4(color,1.0);
}

有什么解决办法吗?

stepsmootstep 是两个具有不同签名和行为的函数。 step 在边缘处生成从 0 到 1 的硬过渡,而 smoothstep 在 2 个值之间平滑插值。

如 Khronos 参考中所述,smoothstep 有 3 个参数:

genType smoothstep( genType edge0, genType edge1, genType x );
  • edge0指定Hermite函数下沿的值。
  • edge1指定Hermite函数的上边缘值。
  • x 指定插值的源值。

smoothstep performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1. This is useful in cases where a threshold function with a smooth transition is desired.

相比之下,step 有 2 个参数:

genType step( genType edge, genType x);
  • edge 指定阶跃函数边缘的位置。
  • x指定用于生成阶跃函数的值。

step generates a step function by comparing x to edge.
For element i of the return value, 0.0 is returned if x[i] < edge[i], and 1.0 is returned otherwise.