effect文件报错

  • Creator 版本:2.4.5

  • 目标平台:

  • 重现方式:

  • 首个报错:

  • 之前哪个版本是正常的:

  • 手机型号:

  • 手机浏览器:

  • 编辑器操作系统:

  • 重现概率:
    // Copyright © 2017-2018 Xiamen Yaji Software Co., Ltd.

// Note: Current format version is experiment, the format may be changed.
// The future format may not be compatible, you may need to update the script manually.

// 注意:当前版本的格式是实验性的,之后还会进行修改。
// 后续版本的格式不保证兼容当前格式,可能需要手动升级到最新版本。,
CCEffect %{
techniques:

  • passes:
    • vert: vs
      frag: fs
      rasterizerState:
      cullMode: none
      blendState:
      targets:
      • blend: true
        layer: 0
        properties:
        texture:
        type: sampler2D
        value: ‘’
        color:
        type: vec4
        displayName: ‘颜色’
        value:
      • 1
      • 1
      • 1
      • 1
        width:
        type: float
        displayName: ‘流光的宽度范围’
        value: 0.08
        time:
        type: float
        displayName: ‘时间’
        value: 1
        strength:
        type: float
        displayName: ‘流光增亮强度’
        value: 0.008
        offset:
        type: float
        displayName: ‘偏移值’
        value: 0.5
        }%

CCProgram vs %{

precision highp float;

#include
#include

in vec3 a_position;
in vec2 a_uv0;
out vec2 uv0;
void main () {
vec4 pos = cc_matViewProj * vec4(a_position, 1);
gl_Position = pos;
uv0 = a_uv0;
}
}%

CCProgram fs %{

precision highp float;

#include
uniform sampler2D texture;
uniform vec4 color;
uniform float time;

uniform float width;
uniform float strength;
uniform float offset;
in vec2 uv0;

void main()
{
vec4 src_color = color * texture2D(texture, uv0).rgba;
float start = tan(time/1.414); //流光的起始x坐标

    if(uv0.x < (start - offset * uv0.y) &&  uv0.x > (start - offset * uv0.y - width))
    {
        vec3 improve = strength * vec3(255, 255, 255);
        vec3 result = improve * vec3( src_color.r, src_color.g, src_color.b);
        gl_FragColor = vec4(result, src_color.a);

    }else{
        gl_FragColor = src_color;
    }
}

}%

shaper是啥

改了,effect 文件报错

报错写的很清楚了啊,uniform要写在block里https://docs.cocos.com/creator3d/manual/zh/material-system/effect-syntax.html#%E5%85%B3%E4%BA%8E-ubo-%E5%86%85%E5%AD%98%E5%B8%83%E5%B1%80

新加的参数得括起来

uniform my{
  vec4 color;
  float time;
  float width;
  float strength;
  float offset;
};

所以我要怎么写在block里,我看你的uniform my 这个my 是啥

uniform sampler2D texture;
uniform IncorrectUBOOrder {
vec4 color;
float time;
float width;
float time;
float strength;
float offset;
};
这样就可以了