简体   繁体   English

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

[英]'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. stepsmootstep是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 element i of the return value, 0.0 is returned if x[i] < edge[i] , and 1.0 is returned otherwise. 对于返回值的元素iif x[i] < edge[i]则返回0.0,否则返回1.0。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 片段着色器:“未找到匹配的重载函数”错误 - Fragment shader: “no matching overloaded function found” error “纹理”:没有找到匹配的重载 function,即使它*应该*符合文档 - 'texture' : no matching overloaded function found even though it *should* comply with documentation &#39;sqrt&#39;:对重载函数.. \\ assimp \\ vector3.inl的模糊调用 - 'sqrt' : ambiguous call to overloaded function ..\assimp\vector3.inl OpenGL:没有用于调用“ glutDisplayFunc”的匹配函数 - OpenGL:no matching function for call to 'glutDisplayFunc' g++11 错误 C1101 中的 OpenGL GSL 着色器构建错误:不明确的重载函数引用“mod(uint, float)” - OpenGL GSL shader build error in g++11 error C1101: ambiguous overloaded function reference "mod(uint, float)" 在Maverick上使用GLFW3的C ++代码:glShaderSource没有匹配功能 - C++ code using GLFW3 on Maverick: glShaderSource no matching function LWJGL3:重载的glBufferData方法 - LWJGL3: Overloaded glBufferData methods 带有Cocoa的OpenGL:尝试调用CGLLockContext([[self openGLContext] CGLContextObj])时,没有匹配的函数调用; - OpenGL with Cocoa: No matching function call when trying to call CGLLockContext([[self openGLContext] CGLContextObj]); 为什么我的几何着色器“过载”? - Why is my geometry shader becoming “overloaded”? freeglut(./ light):错误:内部错误 <FBConfig with necessary capabilities not found> 在函数fgOpenWindow中 - freeglut (./light): ERROR: Internal error <FBConfig with necessary capabilities not found> in function fgOpenWindow
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM