mirror of
https://github.com/ifengzp/cocos-awesome.git
synced 2025-10-09 16:45:51 +00:00
feat: 增加其他场景切换效果
This commit is contained in:
22
assets/Scene/SwitchScene__Strip/Materials/strip-lt.mtl
Normal file
22
assets/Scene/SwitchScene__Strip/Materials/strip-lt.mtl
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"__type__": "cc.Material",
|
||||
"_name": "strip-lt",
|
||||
"_objFlags": 0,
|
||||
"_native": "",
|
||||
"_effectAsset": {
|
||||
"__uuid__": "6b233ee2-ef6d-4ee5-9b24-999badfcff68"
|
||||
},
|
||||
"_techniqueIndex": 0,
|
||||
"_techniqueData": {
|
||||
"0": {
|
||||
"props": {
|
||||
"direction": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": -1,
|
||||
"y": 1
|
||||
}
|
||||
},
|
||||
"defines": {}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.3",
|
||||
"uuid": "ee73e8c0-5ff0-486a-bcdf-dec85b04755b",
|
||||
"dataAsSubAsset": null,
|
||||
"subMetas": {}
|
||||
}
|
140
assets/Scene/SwitchScene__Strip/Materials/strip.effect
Normal file
140
assets/Scene/SwitchScene__Strip/Materials/strip.effect
Normal file
@@ -0,0 +1,140 @@
|
||||
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
CCEffect %{
|
||||
techniques:
|
||||
- passes:
|
||||
- vert: vs
|
||||
frag: fs
|
||||
blendState:
|
||||
targets:
|
||||
- blend: true
|
||||
rasterizerState:
|
||||
cullMode: none
|
||||
properties:
|
||||
texture: { value: white }
|
||||
texture2: { value: white }
|
||||
time: { value: 0 }
|
||||
direction: { value: [1, 1]}
|
||||
}%
|
||||
|
||||
CCProgram transition %{
|
||||
|
||||
// https://www.shadertoy.com/view/ls3cDB
|
||||
|
||||
const float PI = 3.141592653589793;
|
||||
const float PI_2 = 3.141592653589793;
|
||||
|
||||
#define radius .1
|
||||
|
||||
uniform Transition {
|
||||
vec2 direction; // = [1, 1]
|
||||
};
|
||||
|
||||
float aspect = 1.;//screenSize.x / screenSize.y;
|
||||
|
||||
vec4 iMouse = vec4(
|
||||
screenSize.x * (mod((1.0 + time * direction.x), 1.0) + 0.2 * sign(direction.x)),
|
||||
screenSize.y * (mod((1.0 + time * direction.y), 1.0) + 0.2 * sign(direction.y)),
|
||||
screenSize.x * (1.0 - step(0.0, direction.x)),
|
||||
screenSize.y * (1.0 - step(0.0, direction.y))
|
||||
);
|
||||
|
||||
|
||||
vec2 mouse = iMouse.xy * vec2(aspect, 1.) / screenSize.xy;
|
||||
vec2 mouseDir = normalize(abs(iMouse.zw) - iMouse.xy);
|
||||
|
||||
vec4 transition(vec2 uv) {
|
||||
// vec2 uv = fragCoord * vec2(aspect, 1.) / screenSize.xy;
|
||||
|
||||
float dist = dot(uv - mouse, mouseDir);
|
||||
vec2 linePoint = uv - dist * mouseDir;
|
||||
|
||||
vec4 fragColor = vec4(1.0);
|
||||
if (dist > radius) {
|
||||
fragColor = texture(texture2, uv);
|
||||
// add shadow
|
||||
// fragColor.rgb *= pow(clamp(dist - radius, 0., 1.) * 1.5, .2);
|
||||
}
|
||||
else if (dist >= 0.) {
|
||||
// map to cylinder point
|
||||
float theta = asin(dist / radius);
|
||||
vec2 p2 = linePoint + mouseDir * (PI - theta) * radius;
|
||||
vec2 p1 = linePoint + mouseDir * theta * radius;
|
||||
uv = (p2.x <= aspect && p2.y <= 1. && p2.x > 0. && p2.y > 0.) ? p2 : p1;
|
||||
fragColor = texture(texture, uv);
|
||||
fragColor.rgb *= pow(clamp((radius - dist) / radius, 0., 1.), .2);
|
||||
}
|
||||
else {
|
||||
vec2 p = linePoint + mouseDir * (abs(dist) + PI * radius);
|
||||
uv = (p.x <= aspect && p.y <= 1. && p.x > 0. && p.y > 0.) ? p : uv;
|
||||
fragColor = texture(texture, uv);
|
||||
}
|
||||
|
||||
return fragColor;
|
||||
}
|
||||
|
||||
}%
|
||||
|
||||
CCProgram vs %{
|
||||
|
||||
precision highp float;
|
||||
|
||||
#include <cc-global>
|
||||
#include <cc-local>
|
||||
|
||||
in vec3 a_position;
|
||||
in lowp vec4 a_color;
|
||||
|
||||
in mediump vec2 a_uv0;
|
||||
out mediump vec2 v_uv0;
|
||||
|
||||
out lowp vec4 v_color;
|
||||
|
||||
uniform Time {
|
||||
vec2 screenSize;
|
||||
float time;
|
||||
};
|
||||
|
||||
void main() {
|
||||
mat4 mvp;
|
||||
|
||||
mvp = cc_matViewProj;
|
||||
|
||||
v_uv0 = a_uv0;
|
||||
v_color = a_color;
|
||||
|
||||
gl_Position = mvp * vec4(a_position, 1);
|
||||
}
|
||||
|
||||
}%
|
||||
|
||||
CCProgram fs %{
|
||||
|
||||
precision highp float;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D texture2;
|
||||
in mediump vec2 v_uv0;
|
||||
|
||||
uniform Time {
|
||||
vec2 screenSize;
|
||||
float time;
|
||||
};
|
||||
|
||||
in lowp vec4 v_color;
|
||||
|
||||
vec4 getFromColor(vec2 uv) {
|
||||
return texture(texture, uv);
|
||||
}
|
||||
|
||||
vec4 getToColor(vec2 uv) {
|
||||
return texture(texture2, uv);
|
||||
}
|
||||
|
||||
#include <transition>
|
||||
|
||||
void main () {
|
||||
gl_FragColor = v_color * transition(v_uv0);
|
||||
}
|
||||
|
||||
}%
|
17
assets/Scene/SwitchScene__Strip/Materials/strip.effect.meta
Normal file
17
assets/Scene/SwitchScene__Strip/Materials/strip.effect.meta
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"ver": "1.0.25",
|
||||
"uuid": "6b233ee2-ef6d-4ee5-9b24-999badfcff68",
|
||||
"compiledShaders": [
|
||||
{
|
||||
"glsl1": {
|
||||
"vert": "\nprecision highp float;\nuniform mediump mat4 cc_matViewProj;\nattribute vec3 a_position;\nattribute lowp vec4 a_color;\nattribute mediump vec2 a_uv0;\nvarying mediump vec2 v_uv0;\nvarying lowp vec4 v_color;\nvoid main() {\n mat4 mvp;\n mvp = cc_matViewProj;\n v_uv0 = a_uv0;\n v_color = a_color;\n gl_Position = mvp * vec4(a_position, 1);\n}",
|
||||
"frag": "\nprecision highp float;\nuniform sampler2D texture;\nuniform sampler2D texture2;\nvarying mediump vec2 v_uv0;\nuniform vec2 screenSize;\nuniform float time;\nvarying lowp vec4 v_color;\nconst float PI = 3.141592653589793;\nconst float PI_2 = 3.141592653589793;\nuniform vec2 direction;\nfloat aspect = 1.;\nvec4 iMouse = vec4(\n screenSize.x * (mod((1.0 + time * direction.x), 1.0) + 0.2 * sign(direction.x)),\n screenSize.y * (mod((1.0 + time * direction.y), 1.0) + 0.2 * sign(direction.y)),\n screenSize.x * (1.0 - step(0.0, direction.x)),\n screenSize.y * (1.0 - step(0.0, direction.y))\n);\nvec2 mouse = iMouse.xy * vec2(aspect, 1.) / screenSize.xy;\nvec2 mouseDir = normalize(abs(iMouse.zw) - iMouse.xy);\nvec4 transition(vec2 uv) {\n float dist = dot(uv - mouse, mouseDir);\n vec2 linePoint = uv - dist * mouseDir;\n vec4 fragColor = vec4(1.0);\n if (dist > .1) {\n fragColor = texture2D(texture2, uv);\n }\n else if (dist >= 0.) {\n float theta = asin(dist / .1);\n vec2 p2 = linePoint + mouseDir * (PI - theta) * .1;\n vec2 p1 = linePoint + mouseDir * theta * .1;\n uv = (p2.x <= aspect && p2.y <= 1. && p2.x > 0. && p2.y > 0.) ? p2 : p1;\n fragColor = texture2D(texture, uv);\n fragColor.rgb *= pow(clamp((.1 - dist) / .1, 0., 1.), .2);\n }\n else {\n vec2 p = linePoint + mouseDir * (abs(dist) + PI * .1);\n uv = (p.x <= aspect && p.y <= 1. && p.x > 0. && p.y > 0.) ? p : uv;\n fragColor = texture2D(texture, uv);\n }\n return fragColor;\n}\nvoid main () {\n gl_FragColor = v_color * transition(v_uv0);\n}"
|
||||
},
|
||||
"glsl3": {
|
||||
"vert": "\nprecision highp float;\nuniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_nativeSize;\n highp mat4 cc_matView;\n mediump mat4 cc_matViewInv;\n mediump mat4 cc_matProj;\n mediump mat4 cc_matProjInv;\n mediump mat4 cc_matViewProj;\n mediump mat4 cc_matViewProjInv;\n mediump vec4 cc_cameraPos;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin lowp vec4 a_color;\nin mediump vec2 a_uv0;\nout mediump vec2 v_uv0;\nout lowp vec4 v_color;\nuniform Time {\n vec2 screenSize;\n float time;\n};\nvoid main() {\n mat4 mvp;\n mvp = cc_matViewProj;\n v_uv0 = a_uv0;\n v_color = a_color;\n gl_Position = mvp * vec4(a_position, 1);\n}",
|
||||
"frag": "\nprecision highp float;\nuniform sampler2D texture;\nuniform sampler2D texture2;\nin mediump vec2 v_uv0;\nuniform Time {\n vec2 screenSize;\n float time;\n};\nin lowp vec4 v_color;\nconst float PI = 3.141592653589793;\nconst float PI_2 = 3.141592653589793;\nuniform Transition {\n vec2 direction;\n};\nfloat aspect = 1.;\nvec4 iMouse = vec4(\n screenSize.x * (mod((1.0 + time * direction.x), 1.0) + 0.2 * sign(direction.x)),\n screenSize.y * (mod((1.0 + time * direction.y), 1.0) + 0.2 * sign(direction.y)),\n screenSize.x * (1.0 - step(0.0, direction.x)),\n screenSize.y * (1.0 - step(0.0, direction.y))\n);\nvec2 mouse = iMouse.xy * vec2(aspect, 1.) / screenSize.xy;\nvec2 mouseDir = normalize(abs(iMouse.zw) - iMouse.xy);\nvec4 transition(vec2 uv) {\n float dist = dot(uv - mouse, mouseDir);\n vec2 linePoint = uv - dist * mouseDir;\n vec4 fragColor = vec4(1.0);\n if (dist > .1) {\n fragColor = texture(texture2, uv);\n }\n else if (dist >= 0.) {\n float theta = asin(dist / .1);\n vec2 p2 = linePoint + mouseDir * (PI - theta) * .1;\n vec2 p1 = linePoint + mouseDir * theta * .1;\n uv = (p2.x <= aspect && p2.y <= 1. && p2.x > 0. && p2.y > 0.) ? p2 : p1;\n fragColor = texture(texture, uv);\n fragColor.rgb *= pow(clamp((.1 - dist) / .1, 0., 1.), .2);\n }\n else {\n vec2 p = linePoint + mouseDir * (abs(dist) + PI * .1);\n uv = (p.x <= aspect && p.y <= 1. && p.x > 0. && p.y > 0.) ? p : uv;\n fragColor = texture(texture, uv);\n }\n return fragColor;\n}\nvoid main () {\n gl_FragColor = v_color * transition(v_uv0);\n}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
Reference in New Issue
Block a user