自己写了个 shader,在编辑器能显示,运行之后就不显示。
然后就用了一下官方默认的 effect,sprite 的 package 也取消勾选了,运行之后竟然也显示不出来。
控制台:GL_INVALID_OPERATION: It is undefined behaviour to have a used but unbound uniform buffer.
这是为啥啊???????
这对于新手写cocos 的 shader 也太多坑了吧!
默认 effect:
CCEffect %{
techniques:
- name: opaque
passes:- vert: legacy/main-functions/general-vs:vert # builtin header
frag: unlit-fs:frag
properties: &props
mainTexture: { value: white }
mainColor: { value: [1, 1, 1, 1], editor: { type: color } }
- vert: legacy/main-functions/general-vs:vert # builtin header
- name: transparent
passes:- vert: general-vs:vert # builtin header
frag: unlit-fs:frag
blendState:
targets:- blend: true
blendSrc: src_alpha
blendDst: one_minus_src_alpha
blendSrcAlpha: src_alpha
blendDstAlpha: one_minus_src_alpha
properties: *props
}%
- blend: true
- vert: general-vs:vert # builtin header
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);
}
}%
。删掉这一段就可以了