openfl.display.Shader 错误:编译片段着色器时出错

openfl.display.Shader 错误:编译片段着色器时出错

11 个月前有人问过类似的问题,但没有得到答复,所以我决定再次提出这个问题,因为我也有同样的问题。

---------------------------
Error
---------------------------
[openfl.display.Shader] ERROR: Error compiling fragment shader
ERROR: 0:133: 'lerp_' : no matching overloaded function found 
ERROR: 0:133: '' : compilation terminated 
ERROR: 2 compilation errors.  No code generated.
 
 
#ifdef GL_ES
                #ifdef GL_FRAGMENT_PRECISION_HIGH
                precision highp float;
                #else
                precision mediump float;
                #endif
                #endif
 
    varying float openfl_Alphav;
        varying vec4 openfl_ColorMultiplierv;
        varying vec4 openfl_ColorOffsetv;
        varying vec2 openfl_TextureCoordv;
 
        uniform bool openfl_HasColorTransform;
        uniform vec2 openfl_TextureSize;
        uniform sampler2D bitmap;
 
        uniform bool hasTransform;
        uniform bool hasColorTransform;
 
        vec4 flixel_texture2D(sampler2D bitmap, vec2 coord)
        {
            vec4 color = texture2D(bitmap, coord);
            if (!hasTransform)
            {
                return color;
            }
 
            if (color.a == 0.0)
            {
                return vec4(0.0, 0.0, 0.0, 0.0);
            }
 
            if (!hasColorTransform)
            {
                return color * openfl_Alphav;
            }
 
            color = vec4(color.rgb / color.a, color.a);
 
            mat4 colorMultiplier = mat4(0);
            colorMultiplier[0][0] = openfl_ColorMultiplierv.x;
            colorMultiplier[1][1] = openfl_ColorMultiplierv.y;
            colorMultiplier[2][2] = openfl_ColorMultiplierv.z;
            colorMultiplier[3][3] = openfl_ColorMultiplierv.w;
 
            color = clamp(openfl_ColorOffsetv + (color * colorMultiplier), 0.0, 1.0);
 
            if (color.a > 0.0)
            {
                return vec4(color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav);
            }
            return vec4(0.0, 0.0, 0.0, 0.0);
        }
 
 
    #line 17
 
    uniform float iTime;
    uniform bool vignetteOn;
    uniform bool perspectiveOn;
    uniform bool distortionOn;
    uniform bool scanlinesOn;
    uniform bool vignetteMoving;
    uniform float glitchModifier;
 
    float rand(vec2 co){
      return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
    }
 
    float onOff(float a, float b, float c)
    {
        return step(c, sin(iTime + a*cos(iTime*b)));
    }
 
    float ramp(float y, float start, float end)
    {
        float inside = step(start,y) - step(end,y);
        float fact = (y-start)/(end-start)*inside;
        return (1.-fact) * inside;
 
    }
 
    vec4 getVideo(vec2 uv)
      {
        vec2 look = uv;
        if(distortionOn){
            float window = 1./(1.+20.*(look.y-mod(iTime/4.,1.))*(look.y-mod(iTime/4.,1.)));
            look.x = look.x + (sin(look.y*10. + iTime)/50.*onOff(4.,4.,.3)*(1.+cos(iTime*80.))*window)*(glitchModifier*2.);
            float vShift = 0.4*onOff(2.,3.,.9)*(sin(iTime)*sin(iTime*20.) +
                                                 (0.5 + 0.1*sin(iTime*200.)*cos(iTime)));
            look.y = mod(look.y + vShift*glitchModifier, 1.);
        }
        vec4 video = flixel_texture2D(bitmap,look);
 
        return video;
      }
 
    vec2 screenDistort(vec2 uv)
    {
      if(perspectiveOn){
        uv = (uv - 0.5) * 2.0;
        uv *= 1.1;
        uv.x *= 1.0 + pow((abs(uv.y) / 5.0), 2.0);
        uv.y *= 1.0 + pow((abs(uv.x) / 4.0), 2.0);
        uv  = (uv / 2.0) + 0.5;
        uv =  uv *0.92 + 0.04;
        return uv;
      }
        return uv;
    }
    float random(vec2 uv)
    {
        return fract(sin(dot(uv, vec2(15.5151, 42.2561))) * 12341.14122 * sin(iTime * 0.03));
    }
    float noise(vec2 uv)
    {
        vec2 i = floor(uv);
        vec2 f = fract(uv);
 
        float a = random(i);
        float b = random(i + vec2(1.,0.));
        float c = random(i + vec2(0., 1.));
        float d = random(i + vec2(1.));
 
        vec2 u = smoothstep(0., 1., f);
 
        return mix(a,b, u.x) + (c - a) * u.y * (1. - u.x) + (d - b) * u.x * u.y;
 
    }
 
 
    vec2 scandistort(vec2 uv) {
        float scan1 = clamp(cos(uv.y * 2.0 + iTime), 0.0, 1.0);
        float scan2 = clamp(cos(uv.y * 2.0 + iTime + 4.0) * 10.0, 0.0, 1.0) ;
        float amount = scan1 * scan2 * uv.x;
 
        uv.x -= 0.05 * mix(rand(uv+iTime) * amount, amount, 0.9);
 
        return uv;
 
    }
    float lerp_(float a, float b, float t) {
      return b*t + (1.0-t) * a;
    }
    void main()
    {
        vec2 uv = openfl_TextureCoordv;
      vec2 curUV = screenDistort(uv);
        uv = curUV; //scandistort(curUV);
        vec4 video = getVideo(uv);
      float vigAmt = 1.0;
      float x =  0.;
 
    #if 0
      video.r = getVideo(vec2(x+uv.x+0.001,uv.y+0.001)).x+0.05;
      video.g = getVideo(vec2(x+uv.x+0.000,uv.y-0.002)).y+0.05;
      video.b = getVideo(vec2(x+uv.x-0.002,uv.y+0.000)).z+0.05;
      video.r += 0.08*getVideo(0.75*vec2(x+0.025, -0.027)+vec2(uv.x+0.001,uv.y+0.001)).x;
      video.g += 0.05*getVideo(0.75*vec2(x+-0.022, -0.02)+vec2(uv.x+0.000,uv.y-0.002)).y;
      video.b += 0.08*getVideo(0.75*vec2(x+-0.02, -0.018)+vec2(uv.x-0.002,uv.y+0.000)).z;
    #else
      video = getVideo(vec2(x+uv.x+0.000,uv.y-0.002)) + 0.05;
    #endif
 
      video = clamp(video*0.6+0.4*video*video*1.0,0.0,1.0);
      if(vignetteMoving)
          vigAmt = 3.+.3*sin(iTime + 5.*cos(iTime*5.));
 
        float vignette = (1.-vigAmt*(uv.y-.5)*(uv.y-.5))*(1.-vigAmt*(uv.x-.5)*(uv.x-.5));
 
      if(vignetteOn)
        video *= vec4(vec3(vignette), lerp_(vignette, 1.0, 1));
 
 
      gl_FragColor = mix(video,vec4(noise(uv * 75.) * abs(sin(iTime)) ),.05);
 
      if(curUV.x<0. || curUV.x>1. || curUV.y<0. || curUV.y>1.){
        gl_FragColor = vec4(0,0,0,0);
      }
 
    }
 
---------------------------
ОК   
---------------------------

CPU - Intel(R) Xeon(R) CPU X5650 @ 2.67GHz 2.66 GHz

内存 - 16,0 GB

系统类型 - 64 位操作系统,x64 CPU

Windows 10 版本 21H2

我几乎在任何使用着色器的 Friday Night Funkin' 模组中都遇到了此错误。(是的,是的,Friday Night Funkin'。看,此错误显然与任何简单模组无关 - 如果相关,它就不会到处发生!我会说 OpenFL 出了问题,因为每次都是同样的错误。)

知道该怎么办吗?这种情况已经持续了一段时间,只是我厌倦了这种情况,想让它恢复正常。这种情况已经持续了一段时间,所以我不记得当这种情况开始发生时我在做什么。

提前致谢!

相关内容