【发布时间】:2020-08-01 01:06:31
【问题描述】:
我有一个简单的着色器(Cocos Creator 中的.effect 文件),它具有可以在材质属性窗口中修改的颜色属性。检查代码示例和图像以供参考。
如何制作一组颜色?我希望能够在材质属性窗口的数组中指定任意数量的颜色。
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;
}
}%
【问题讨论】:
标签: yaml glsl cocoscreator