92 lines
2.0 KiB
Plaintext
92 lines
2.0 KiB
Plaintext
CCEffect %{
|
|
techniques:
|
|
- passes:
|
|
- vert: shop-jungle-shine-vs
|
|
frag: shop-jungle-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] }
|
|
}%
|
|
|
|
CCProgram shop-jungle-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-jungle-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;
|
|
float shinePosition;
|
|
float shineWidth;
|
|
float shineStrength;
|
|
float shineAngle;
|
|
};
|
|
|
|
void main () {
|
|
vec4 color = vec4(1.0);
|
|
CCTexture(texture, v_uv0, color);
|
|
color *= v_color;
|
|
|
|
float sweepAxis = v_uv0.x + (v_uv0.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);
|
|
color.rgb += shineColor.rgb * shine * shineStrength * color.a;
|
|
|
|
ALPHA_TEST(color);
|
|
#if USE_BGRA
|
|
gl_FragColor = color.bgra;
|
|
#else
|
|
gl_FragColor = color.rgba;
|
|
#endif
|
|
}
|
|
}%
|