You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.7 KiB
82 lines
1.7 KiB
// 城堡损伤:主纹理为 Sprite 原图,damageMask.r 为 1=保留、0=击穿(与城堡同 UV)
|
|
|
|
CCEffect %{
|
|
techniques:
|
|
- passes:
|
|
- vert: sprite-vs:vert
|
|
frag: castle-damage-fs:frag
|
|
depthStencilState:
|
|
depthTest: false
|
|
depthWrite: false
|
|
blendState:
|
|
targets:
|
|
- blend: true
|
|
blendSrc: src_alpha
|
|
blendDst: one_minus_src_alpha
|
|
blendDstAlpha: one_minus_src_alpha
|
|
rasterizerState:
|
|
cullMode: none
|
|
properties:
|
|
alphaThreshold: { value: 0.5 }
|
|
damageMask: { value: white }
|
|
}%
|
|
|
|
CCProgram sprite-vs %{
|
|
precision highp float;
|
|
#include <builtin/uniforms/cc-global>
|
|
#if USE_LOCAL
|
|
#include <builtin/uniforms/cc-local>
|
|
#endif
|
|
#if SAMPLE_FROM_RT
|
|
#include <common/common-define>
|
|
#endif
|
|
in vec3 a_position;
|
|
in vec2 a_texCoord;
|
|
in vec4 a_color;
|
|
|
|
out vec4 color;
|
|
out vec2 uv0;
|
|
|
|
vec4 vert() {
|
|
vec4 pos = vec4(a_position, 1.0);
|
|
#if USE_LOCAL
|
|
pos = cc_matWorld * pos;
|
|
#endif
|
|
#if USE_PIXEL_ALIGNMENT
|
|
pos = cc_matView * pos;
|
|
pos.xyz = floor(pos.xyz);
|
|
pos = cc_matProj * pos;
|
|
#else
|
|
pos = cc_matViewProj * pos;
|
|
#endif
|
|
uv0 = a_texCoord;
|
|
#if SAMPLE_FROM_RT
|
|
CC_HANDLE_RT_SAMPLE_FLIP(uv0);
|
|
#endif
|
|
color = a_color;
|
|
return pos;
|
|
}
|
|
}%
|
|
|
|
CCProgram castle-damage-fs %{
|
|
precision highp float;
|
|
#include <builtin/internal/embedded-alpha>
|
|
#include <builtin/internal/alpha-test>
|
|
|
|
in vec4 color;
|
|
in vec2 uv0;
|
|
|
|
#pragma builtin(local)
|
|
layout(set = 2, binding = 12) uniform sampler2D cc_spriteTexture;
|
|
|
|
uniform sampler2D damageMask;
|
|
|
|
vec4 frag() {
|
|
vec4 o = texture(cc_spriteTexture, uv0);
|
|
o *= color;
|
|
float m = texture(damageMask, uv0).r;
|
|
o.a *= m;
|
|
ALPHA_TEST(o);
|
|
return o;
|
|
}
|
|
}%
|
|
|