GL_INVALID_OPERATION: glDrawElements: It is undefined behaviour to have a used but unbound uniform buffer.

3.8.6,浏览器不能显示,引擎可以,为啥 :joy:image
CCEffect %{

techniques:

  • passes:

    • vert: vs:vert

      frag: fs:frag

      rasterizerState:

      cullMode: none

      blendState:

      targets:

      • blend: true

      properties:

      mainTexture: { value: white }

      amplitude: { value: 10.0 }

      frequency: { value: 5.0 }

      speed: { value: 2.0 }

      warpType: { value: 0 }

}%

CCProgram vs %{

precision highp float;

#include <builtin/uniforms/cc-global>

#include <builtin/uniforms/cc-local>

in vec3 a_position;

in vec2 a_texCoord;

out vec2 v_uv;

// 必须用 uniform block

uniform EffectUniforms {

  float amplitude;

  float frequency;

  float speed;

  float warpType;

};

vec3 waveWarp(vec3 pos) {

  pos.y += sin(

      pos.x * frequency * 0.01 +

      cc_time.x * speed

  ) * amplitude;

  return pos;

}

vec3 jellyWarp(vec3 pos) {

  float dist = length(pos.xy);

  float offset = sin(

      dist * 0.05 -

      cc_time.x * speed

  );

  vec2 dir = normalize(pos.xy + 0.0001);

  pos.xy += dir * offset * amplitude;

  return pos;

}

vec4 vert () {

  vec3 pos = a_position;

  if (warpType < 0.5) {

      pos = waveWarp(pos);

  } else {

      pos = jellyWarp(pos);

  }

  v_uv = a_texCoord;

  return cc_matViewProj * cc_matWorld * vec4(pos, 1.0);

}

}%

CCProgram fs %{

precision highp float;

in vec2 v_uv;

uniform sampler2D mainTexture;

vec4 frag () {

  return texture(mainTexture, v_uv);

}

}%

3.x的shader我不熟,
你是不是可以考虑copy一份默认的sprite材质出来修改调试

好吧 :joy: