Files
cocos-engine/editor/assets/effects/util/sequence-anim.effect
jk20012001 3cf9aaee4e arrange chunks (#11551)
* arrange chunks

* update compiled shaders

* code style
2022-06-16 22:14:09 +08:00

168 lines
4.3 KiB
Plaintext

// Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
CCEffect %{
techniques:
- name: opaque
passes:
- vert: unlit-vs:vert
frag: unlit-fs:frag
properties: &props
mainTexture: { value: grey }
tilingOffset: { value: [1, 1, 0, 0] }
mainColor: { value: [1, 1, 1, 1], editor: { type: color } }
colorScale: { value: [1, 1, 1], target: colorScaleAndCutoff.xyz }
alphaThreshold: { value: 0.5, target: colorScaleAndCutoff.w, editor: { parent: USE_ALPHA_TEST } }
dimensions: { value: [2, 2], target: seqAnimParams.xy }
frames: { value: 4, target: seqAnimParams.z }
speedOrProgress: { value: 10, target: seqAnimParams.w }
migrations: &migs
properties:
dimensions: { formerlySerializedAs: constants.xy }
frames: { formerlySerializedAs: constants.z }
speedOrProgress: { formerlySerializedAs: constants.w }
mainTexture: { formerlySerializedAs: seqTexture }
mainColor: { formerlySerializedAs: weight }
- name: transparent
passes:
- vert: unlit-vs:vert
frag: unlit-fs:frag
depthStencilState: &d1
depthTest: true
depthWrite: false
blendState:
targets:
- blend: true
blendSrc: src_alpha
blendDst: one_minus_src_alpha
blendDstAlpha: one_minus_src_alpha
properties: *props
migrations: *migs
- name: add
passes:
- vert: unlit-vs:vert
frag: unlit-fs:frag
rasterizerState: &r1 { cullMode: none }
depthStencilState: *d1
blendState:
targets:
- blend: true
blendSrc: src_alpha
blendDst: one
blendSrcAlpha: src_alpha
blendDstAlpha: one
properties: *props
migrations: *migs
- name: alpha-blend
passes:
- vert: unlit-vs:vert
frag: unlit-fs:frag
rasterizerState: *r1
depthStencilState: *d1
blendState:
targets:
- blend: true
blendSrc: src_alpha
blendDst: one_minus_src_alpha
blendSrcAlpha: src_alpha
blendDstAlpha: one_minus_src_alpha
properties: *props
migrations: *migs
}%
CCProgram unlit-vs %{
precision highp float;
#include <legacy/input>
#include <builtin/uniforms/cc-global>
#include <legacy/decode-base>
#include <legacy/local-batch>
#if USE_VERTEX_COLOR
in lowp vec4 a_color;
out lowp vec4 v_color;
#endif
#if USE_TEXTURE
out vec2 v_uv;
uniform TexCoords {
vec4 tilingOffset;
};
#if USE_SEQUENCE_ANIM
uniform SeqAnimConstants {
vec4 seqAnimParams;
};
#endif
#endif
vec4 vert () {
vec4 position;
CCVertInput(position);
mat4 matWorld;
CCGetWorldMatrix(matWorld);
#if USE_TEXTURE
v_uv = a_texCoord;
#if FLIP_UV
v_uv.y = 1.0 - v_uv.y;
#endif
v_uv = v_uv * tilingOffset.xy + tilingOffset.zw;
#if USE_SEQUENCE_ANIM
#if MANUAL_PLAYBACK
float seqAnimCurFrame = clamp(seqAnimParams.w, 0.0, 0.999) * seqAnimParams.z;
#else
float seqAnimCurFrame = mod(cc_time.x, seqAnimParams.z / seqAnimParams.w) * seqAnimParams.w; // iOS precision issue
#endif
vec2 seqAnimOffset = floor(vec2(mod(seqAnimCurFrame, seqAnimParams.x), seqAnimCurFrame / seqAnimParams.x));
v_uv = (v_uv + seqAnimOffset) / seqAnimParams.xy;
#endif
#endif
#if USE_VERTEX_COLOR
v_color = a_color;
#endif
return cc_matProj * (cc_matView * matWorld) * position;
}
}%
CCProgram unlit-fs %{
precision highp float;
#include <legacy/output>
#if USE_ALPHA_TEST
#pragma define-meta ALPHA_TEST_CHANNEL options([a, r, g, b])
#endif
#if USE_TEXTURE
in vec2 v_uv;
uniform sampler2D mainTexture;
#endif
uniform Constant {
vec4 mainColor;
vec4 colorScaleAndCutoff;
};
#if USE_VERTEX_COLOR
in lowp vec4 v_color;
#endif
vec4 frag () {
vec4 o = mainColor;
o.rgb *= colorScaleAndCutoff.xyz;
#if USE_VERTEX_COLOR
o *= v_color;
#endif
#if USE_TEXTURE
o *= texture(mainTexture, v_uv);
#endif
#if USE_ALPHA_TEST
if (o.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;
#endif
return CCFragOutput(o);
}
}%