遇到effect在编辑器可行,但是浏览器模拟器不可行的问题

大家好,我最近正在学习使用cocos creator3.8.6版本,我用ai帮我写了一个effect,在编辑器中能正常看到效果。但是浏览器和模拟器运行就会看不到效果,浏览器上报错内容如下:
[.WebGL-0x66240144a900] GL_INVALID_OPERATION: glDrawElements: It is undefined behaviour to have a used but unbound uniform buffer.

effect的内容如下:
CCEffect %{

techniques:

  • name: multiply

    passes:

    • vert: legacy/main-functions/general-vs:vert

      frag: unlit-fs:frag

      blendState:

      targets:

      • blend: true

        blendSrc: dst_color

        blendDst: zero

        blendSrcAlpha: one

        blendDstAlpha: zero

      rasterizerState:

      cullMode: none

      depthStencilState:

      depthTest: false

      depthWrite: false

      properties: &props

      mainTexture: { value: white }

      mainColor: { value: [1, 1, 1, 1], editor: { type: color } }

}%

CCProgram unlit-fs %{

precision highp float;

#include <legacy/output>

#include <legacy/fog-fs>

in vec2 v_uv;

in vec3 v_position;

uniform sampler2D mainTexture;

uniform Constant {

vec4 mainColor;

};

vec4 frag () {

vec4 col = mainColor * texture(mainTexture, v_uv);

CC_APPLY_FOG(col, v_position);

return CCFragOutput(col);

}

}%

#include <legacy/fog-fs>

这个模块很容易出问题的,参考:遇到的一个shader问题,实在找不到解决方案了

建议自己手写 shader 功能,尽量少用内置模块。

P.S. 如果是着色器新手,可以来入门:【新手教程】🚩Cocos Creator 着色器入门(更新到 12 篇文章)

我把这部分修改了一下,把这个fog-fs删了,但还是报同样的错误。
CCEffect %{

techniques:

  • name: multiply

    passes:

    • vert: legacy/main-functions/general-vs:vert

      frag: unlit-fs:frag

      blendState:

      targets:

      • blend: true

        blendSrc: dst_color

        blendDst: zero

        blendSrcAlpha: one

        blendDstAlpha: zero

      rasterizerState:

      cullMode: none

      depthStencilState:

      depthTest: false

      depthWrite: false

      properties: &props

      mainTexture: { value: white }

}%

CCProgram unlit-fs %{

precision highp float;

in vec2 v_uv;

uniform sampler2D mainTexture;

uniform Constant {

vec4 mainColor;

};

vec4 frag () {

vec4 col = mainColor * texture(mainTexture, v_uv);

return col;

}

}%

因为你在 passes 里引入了 legacy/main-functions/general-vs 这个内置模块,里面就有 #include <legacy/local-batch>#include <legacy/fog-vs>