之前有个2.1的版本的shader,我想移植到2.3上,
文章在这:https://github.com/xxc0916/ShadersBookForCocosCreator/blob/master/assets/resources/effects/01_1_Uniform.effect
我的代码
// Copyright © 2017-2018 Xiamen Yaji Software Co., Ltd.
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
alphaThreshold: { value: 0.5 }
u_time: { value: 0.5 }
}%
- blend: true
- vert: vs
CCProgram vs %{
precision highp float;
#include
#include
in vec3 a_position;
in vec4 a_color;
out vec4 v_color;
#if USE_TEXTURE
in vec2 a_uv0;
out vec2 v_uv0;
#endif
void main () {
vec4 pos = vec4(a_position, 1);
#if CC_USE_MODEL
pos = cc_matViewProj * cc_matWorld * pos;
#else
pos = cc_matViewProj * pos;
#endif
#if USE_TEXTURE
v_uv0 = a_uv0;
#endif
v_color = a_color;
gl_Position = pos;
}
}%
CCProgram fs %{
precision highp float;
#include
#include
in vec4 v_color;
#if USE_TEXTURE
in vec2 v_uv0;
uniform sampler2D texture;
#endif
uniform float u_time;
void main () {
float r = abs(sin(u_time));
gl_FragColor = vec4(r, 0., 0., 1.);
}
}%
但是报错 2020-05-12T08:08:16.692Z - error: New Effect.effect - fs - 30: error EFX2201: non-sampler uniforms must be declared in blocks.
请教一下如何写