mirror of
https://github.com/ifengzp/cocos-awesome.git
synced 2024-12-26 11:49:18 +00:00
17 lines
4.4 KiB
Plaintext
17 lines
4.4 KiB
Plaintext
{
|
|
"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": {}
|
|
} |