完整的 effect 代码如下:
CCEffect %{
techniques:
- name: opaque
passes:
- vert: vs:vert
frag: fs:frag
properties:
coverColor: { value: [1.0, 0.0, 0.0, 1.0] } // 这里定义了一个 vec4 属性
}%
CCProgram vs %{
precision highp float;
#include <cc-global>
#if USE_LOCAL
#include <cc-local>
#endif
in vec3 a_position;
in vec2 a_texCoord;
in vec4 a_color;
out vec4 v_light;
out vec2 uv0;
vec4 vert() {
vec4 pos = vec4(a_position, 1);
#if USE_LOCAL
pos = cc_matWorld * pos;
#endif
pos = cc_matViewProj * pos;
v_light = a_color;
uv0 = a_texCoord;
return pos;
}
}%
CCProgram fs %{
precision highp float;
in vec4 v_light;
in vec2 uv0;
uniform Arg {
vec4 coverColor;
};
#pragma builtin(local)
layout() uniform sampler2D cc_spriteTexture;
vec4 frag() {
vec4 o = texture(cc_spriteTexture, uv0);
o.rgb = mix(coverColor.rgb, o.rgb, 0.2);
return o;
}
}%
预期属性检查器里应该显示出这个自定义的 coverColor 属性,但却没有(只显示了一个内置的 USE_LOCAL):
是什么原因呢?



这样?