
拿qq录屏转的gif凑合看下 是有带一点呼吸的动态效果
//战斗状态特效
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white, editor: { visible: false } }
}%
CCProgram vs %{
precision highp float;
#include <cc-global>
#include <cc-local>
in vec3 a_position;
in vec4 a_color;
in vec4 a_color0;
in vec2 a_uv0;
out vec2 v_uv0;
out vec4 v_light;
#if USE_TINT
out vec4 v_dark;
#endif
void main () {
mat4 mvp;
#if CC_USE_MODEL
mvp = cc_matViewProj * cc_matWorld;
#else
mvp = cc_matViewProj;
#endif
v_uv0 = a_uv0;
v_light = a_color;
#if USE_TINT
v_dark = a_color0;
#endif
gl_Position = mvp * vec4(a_position, 1);
}
}%
CCProgram fs %{
precision highp float;
#include <cc-global>
uniform sampler2D texture;
in vec2 v_uv0;
in vec4 v_light;
#if USE_TINT
in vec4 v_dark;
#endif
void main () {
vec4 texColor = vec4(1.0);
texColor *= texture(texture, v_uv0);
vec4 o;
#if USE_TINT
o.a = v_light.a * texColor.a;
o.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
#else
o = texColor * v_light;
#endif
#if frozen //冰冻
float r = abs(o.r - o.g - o.b) * 1.5;
float g = abs(o.g - o.b - o.r) * 1.5;
float b = abs(o.b - o.r - o.g) * 1.5;
o = vec4(r, g, b, o.a);
#endif
#if stone //石化
float gray = (o.r + o.g + o.b) / 3.0;
o = vec4(gray, gray, gray, o.a);
#endif
#if poison //中毒
o.r *= 0.0;
o.g *= 0.8 + sin(cc_time.x * 4.0) * 0.2;
o.b *= 0.0;
#endif
#if burn //灼烧
o.r += abs(sin(cc_time.x * 2.0)) * 0.2;
o.g *= 0.5;
o.b *= 0.5;
#endif
#if hidden //隐身
o.rgb *= 0.9;
o.a *= 0.5+ sin(cc_time.x * 4.0) * 0.1;
#endif
#if golden //金身
o.r *= 1.5 + sin(cc_time.x * 2.0) * 0.2;
o.g = o.r * 0.9;
o.b *= 0.1;
o.a *= 0.9;
#endif
#if virtual //虚化
float edge = max(max(o.r, o.g), o.b) - min(min(o.r, o.g), o.b);
o.rgb = vec3(edge * 2.0) * vec3(0.5, 1.0, 0.8);
o.a *= 0.9+ sin(cc_time.x * 4.0) * 0.1;
#endif
#if slow //迟缓
o.r *= 0.6 + sin(cc_time.x * 1.0) * 0.1;
o.g *= 1.2 + sin(cc_time.x * 1.0) * 0.2;
o.b *= 1.5;
#endif
gl_FragColor = o;
}
}%



