我有一个简单的着色器(.effect
file in Cocos Creator
),其中包含可以在材质的属性窗口中修改的颜色属性。检查代码示例和图像以供参考。
如何制作一组颜色?我希望能够在材料属性窗口的数组中指定任意数量的颜色。
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
alphaThreshold: { value: 0.5 }
color: { value: [1, 1, 1, 1], editor: { type: color }}
}%
CCProgram vs %{
// ...
}%
CCProgram fs %{
precision highp float;
#include <alpha-test>
#include <texture>
in vec4 v_color;
#if USE_TEXTURE
in vec2 v_uv0;
uniform sampler2D texture;
#endif
uniform Data
{
vec4 color;
};
void main()
{
vec4 o = vec4(1, 1, 1, 1);
#if USE_TEXTURE
CCTexture(texture, v_uv0, o);
#endif
o *= v_color;
ALPHA_TEST(o);
gl_FragColor = o;
}
}%