105 lines
2.5 KiB
Plaintext
105 lines
2.5 KiB
Plaintext
CCEffect %{
|
|
techniques:
|
|
- passes:
|
|
- vert: shop-title-shine-vs
|
|
frag: shop-title-shine-fs
|
|
blendState:
|
|
targets:
|
|
- blend: true
|
|
blendSrc: src_alpha
|
|
blendDst: one_minus_src_alpha
|
|
rasterizerState:
|
|
cullMode: none
|
|
depthStencilState:
|
|
depthTest: false
|
|
depthWrite: false
|
|
properties:
|
|
texture: { value: white }
|
|
shinePosition: { value: -0.3 }
|
|
shineWidth: { value: 0.075 }
|
|
shineStrength: { value: 1.8 }
|
|
shineAngle: { value: 0.2 }
|
|
shineColor: { value: [1.0, 0.95, 0.68, 1.0] }
|
|
rainbow: { value: 0.0 }
|
|
uvRect: { value: [0.0, 0.0, 1.0, 1.0] }
|
|
uvRotated: { value: 0.0 }
|
|
}%
|
|
|
|
CCProgram shop-title-shine-vs %{
|
|
precision highp float;
|
|
#include <cc-global>
|
|
#include <cc-local>
|
|
|
|
in vec3 a_position;
|
|
in vec4 a_color;
|
|
in vec2 a_uv0;
|
|
out vec4 v_color;
|
|
out vec2 v_uv0;
|
|
|
|
void main () {
|
|
vec4 pos = vec4(a_position, 1.0);
|
|
#if CC_USE_MODEL
|
|
pos = cc_matViewProj * cc_matWorld * pos;
|
|
#else
|
|
pos = cc_matViewProj * pos;
|
|
#endif
|
|
gl_Position = pos;
|
|
v_color = a_color;
|
|
v_uv0 = a_uv0;
|
|
}
|
|
}%
|
|
|
|
CCProgram shop-title-shine-fs %{
|
|
precision highp float;
|
|
#include <alpha-test>
|
|
#include <texture>
|
|
|
|
in vec4 v_color;
|
|
in vec2 v_uv0;
|
|
uniform sampler2D texture;
|
|
uniform ShineProperties {
|
|
vec4 shineColor;
|
|
vec4 uvRect;
|
|
float shinePosition;
|
|
float shineWidth;
|
|
float shineStrength;
|
|
float shineAngle;
|
|
float rainbow;
|
|
float uvRotated;
|
|
};
|
|
|
|
void main () {
|
|
vec4 color = vec4(1.0);
|
|
CCTexture(texture, v_uv0, color);
|
|
color *= v_color;
|
|
|
|
vec2 localUV = (v_uv0 - uvRect.xy) / max(uvRect.zw, vec2(0.00001));
|
|
if (uvRotated > 0.5) localUV = vec2(localUV.y, 1.0 - localUV.x);
|
|
float sweepAxis = localUV.x + (localUV.y - 0.5) * shineAngle;
|
|
float bandIn = smoothstep(
|
|
shinePosition - shineWidth,
|
|
shinePosition,
|
|
sweepAxis
|
|
);
|
|
float bandOut = 1.0 - smoothstep(
|
|
shinePosition,
|
|
shinePosition + shineWidth,
|
|
sweepAxis
|
|
);
|
|
float shine = pow(clamp(bandIn * bandOut, 0.0, 1.0), 1.35);
|
|
vec3 glowColor = shineColor.rgb;
|
|
if (rainbow > 0.5) {
|
|
float hue = (sweepAxis - shinePosition) / (2.0 * shineWidth) + 0.5;
|
|
glowColor = 0.5 + 0.5 * cos(6.2831853 * (hue + vec3(0.0, 0.666667, 0.333333)));
|
|
}
|
|
color.rgb += glowColor * shine * shineStrength * color.a;
|
|
|
|
ALPHA_TEST(color);
|
|
#if USE_BGRA
|
|
gl_FragColor = color.bgra;
|
|
#else
|
|
gl_FragColor = color.rgba;
|
|
#endif
|
|
}
|
|
}%
|