How to make a color array property for a shader?

I have a simple shader with a property for a color that can be modified in the properties window on a material. Check the code sample and the image for a reference.

How can I make an array of colors? I want to be able to specify any number of colors in an array on a material’s properties window.

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;
  }
}%

image

Not support array properties yet, you need to define a property for each color.

Ah, that’s unfortunate. Thanks for the response!

Would be nice if that would be added in the future. I was planning on making a shader for a gradient that would be able to have any amount of colors in it by grabbing a user defined array.