[英]'smoothstep' : no matching overloaded function found
I am going through the Book of Shaders tutorial on GLSL and I attempt to use the smoothstep
function but I get this error. 我正在阅读有关GLSL的《着色器手册》教程 ,我尝试使用
smoothstep
函数,但出现此错误。 You can see it happen when I changed the step
to the smoothstep
function below. 当我将
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);
}
Any ideas how to fix this? 任何想法如何解决这一问题?
step
and smootstep
are 2 functions with a different signature and behavior. step
和smootstep
是2个功能,具有不同的签名和行为。 While step
generates a hard transition from 0 to 1 at an edge, smoothstep
smoothly interpolates between 2 values. 在
step
在边缘处从0到1产生硬过渡的同时,平滑smoothstep
在2个值之间平滑插值。
As specified in the Khronos reference, smoothstep
has 3 parameters: 如Khronos参考中指定的,
smoothstep
具有3个参数:
genType smoothstep( genType edge0, genType edge1, genType x );
edge0
Specifies the value of the lower edge of the Hermite function. edge0
指定Hermite函数下边缘的值。 edge1
Specifies the value of the upper edge of the Hermite function. edge1
指定Hermite函数的上边缘的值。 x
Specifies the source value for interpolation. x
指定插值的源值。 smoothstep performs smooth Hermite interpolation between 0 and 1 when
edge0 < x < edge1
.当
edge0 < x < edge1
时,edge0 < x < edge1
在0和1之间执行平滑的Hermite插值。 This is useful in cases where a threshold function with a smooth transition is desired.这在需要具有平滑过渡的阈值函数的情况下很有用。
In comparison, step
has 2 parameters: 相比之下,
step
具有2个参数:
genType step( genType edge, genType x);
edge
Specifies the location of the edge of the step function. edge
指定步进功能的边缘位置。 x
Specify the value to be used to generate the step function. x
指定用于生成步进函数的值。
step
generates a step function by comparing x to edge.step
通过将x与edge进行比较来生成step函数。
For elementi
of the return value, 0.0 is returnedif x[i] < edge[i]
, and 1.0 is returned otherwise.对于返回值的元素
i
,if x[i] < edge[i]
则返回0.0,否则返回1.0。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.