0

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

在此处输入图像描述

4

1 回答 1

0

目前没有支持该功能的功能。

来源:https ://discuss.cocos2d-x.org/t/how-to-make-a-color-array-property-for-a-shader/51068/

于 2020-08-13T16:38:14.317 回答