Problem with Material in CC 3.8.6

Hi everyone,

I’m working with Cocos Creator 3.8.6, and I’ve encountered a problem: I’m trying to assign a Material to a Node.

In the editor (inside Cocos Creator), everything looks fine — the Node is visible and the Material is applied correctly.
However, when I run the project in the browser for testing, I always get the following error in the console:

[.WebGL-0x514c076fc700] GL_INVALID_OPERATION: glDrawElements: It is undefined behaviour to have a used but unbound uniform buffer.

Also, the Node with the Material is either not visible at all or appears completely transparent — I’m not sure.

I tried using a .mtl with both the standard .effect and a custom .effect, but there was no difference. It always displays correctly inside the Cocos Creator editor, but not in the browser, and the same error appears in the console.

As a last attempt, I tried using an .effect without any uniform blocks:

CCEffect %{
  techniques:
  - name: opaque
    passes:
    - vert: legacy/main-functions/general-vs:vert # builtin header
      frag: unlit-fs:frag
      properties: &props
        mainTexture:    { value: white }
}%


CCProgram unlit-fs %{
  precision highp float;
  #include <legacy/output>

  in vec2 v_uv;

  uniform sampler2D mainTexture;

  vec4 frag () {
    vec4 col = texture(mainTexture, v_uv);
    return CCFragOutput(col);
  }
}%

but it still didn’t help — again, it worked inside Cocos Creator but not in the browser, and I got the same error.

What do I need to do to correctly use Materials (and custom effects) with my Nodes?

ChatGPT said:

Hey, just chiming in, I ran into a similar issue before in CC 3.8+. That GL INVALID OPERATION error usually means something is referencing a uniform buffer that’s expected but not set correctly at runtime.

Even if you’re not using uniform blocks in your .effect, make sure the pass structure isn’t inheriting a pipeline state or macro that expects one (especially if copied from another shader). Also double-check if the material is getting reset or overridden in code after scene load.

Try logging the material in onLoad() to confirm it’s actually assigned at runtime, not just in-editor. Let us know if that changes anything.