0

我已经将 HSV2RGB 颜色函数从一个工作代码完全复制到了 shadertoy 网站上的另一个代码中,它说 -

  no matching overloaded function found, 
  cannot convert from "constant mediump float" to "3 vector component of float"

这是拒绝工作的功能:

 vec3 hsv2rgb(vec3 c)//<---crashes
 {
  vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
  vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
  return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
 }

这是一个带有错误的示例 glsl 沙箱,https: //www.shadertoy.com/view/MsS3Rh它位于第 24 到 33 行。

4

1 回答 1

1

实际错误是您包含在问题文本中的代码的一部分:

void main(void)
{
    vec3 HSV = hsv2rgb(.1,.2,.3);
                       ~~~~~~~~ BAD!
    ...

要解决此问题,请使用:

vec3 HSV = hsv2rgb (vec3 (.1, .2, .3));
于 2013-11-03T05:54:41.703 回答