如何为着色器创建颜色阵列属性?

时间:2020-08-01 01:06:31

标签: yaml glsl cocoscreator

我有一个简单的着色器(.effect中的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;
  }
}%

enter image description here

1 个答案:

答案 0 :(得分:0)