【发布时间】:2021-09-09 08:58:59
【问题描述】:
我的 glsl 文件出现此错误
no matching overloaded for function 'sqrt' found
这是我的以下代码
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
uniform sampler2D texture;
varying vec4 vertColor;
varying vec4 vertTexCoord;
uniform vec4 targetColor;
uniform float threshold; //between 0 and 1
void main() {
vec4 texColor = texture2D(texture, vertTexCoord.st) * vertColor;
vec3 a = texColor.xyz;
vec3 b = targetColor.xyz;
float dist = sqrt((b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y) + (b.z - a.z) * (b.z - a.z));
bool cond = dist < threshold * sqrt(3);
// if color is within threshold, encode the pixel's position into red and green components
// and use blue component as a marker that the pixel was in range
// vertTexCoord is from 0 to 1, so after computing average, multiply by width and height to get screen position
gl_FragColor = cond ? vec4(vertTexCoord.x, vertTexCoord.y, 1, 1) : vec4(0, 0, 0, 1);
}
【问题讨论】:
标签: image-processing opengl-es glsl shader fragment-shader