Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
9865eedc34 | ||
|
f109455742 | ||
|
95a7a51357 | ||
|
4ed91e0a3e | ||
|
f3c0ad079a | ||
|
f1256c5185 | ||
|
f58540ead2 | ||
|
bfe61e6494 | ||
|
c64f1ab144 | ||
|
deebc64aa2 | ||
|
af8aa46786 | ||
|
4ca3fe34b0 | ||
|
eff439ef20 | ||
|
e257d1f8b9 | ||
|
70a3b95f10 | ||
|
6402c68fbc | ||
|
dccf05cfde | ||
|
1ff0ee3d40 | ||
|
209e22fcca | ||
|
e7e084b958 | ||
|
acf72e0e4f | ||
|
c95329e7ab | ||
|
9160ad38b7 |
@@ -1,5 +1,13 @@
|
|||||||
# ChangeLog
|
# ChangeLog
|
||||||
|
|
||||||
|
## 0.6.0 (2020-01-17)
|
||||||
|
|
||||||
|
- 加入新的圆角裁剪特效 v2 ,支持任意宽高纹理圆角裁剪
|
||||||
|
|
||||||
|
## 0.5.0 (2020-01-13)
|
||||||
|
|
||||||
|
- 加入扫光特效
|
||||||
|
|
||||||
## 0.4.0 (2020-01-12)
|
## 0.4.0 (2020-01-12)
|
||||||
|
|
||||||
- 加入点光特效
|
- 加入点光特效
|
||||||
|
33
README.md
33
README.md
@@ -1,6 +1,6 @@
|
|||||||
# Cocos Creator Shader Effect Demo
|
# Cocos Creator Shader Effect Demo
|
||||||
|
|
||||||
[](CHANGELOG.md)
|
[](CHANGELOG.md)
|
||||||
[](LICENSE)
|
[](LICENSE)
|
||||||
[](http://www.cocos.com/creator)
|
[](http://www.cocos.com/creator)
|
||||||
|
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
* [Cocos Creator Shader Effect 系列 - 4 - 老照片特效](https://www.jianshu.com/p/711a54ff2fa0)
|
* [Cocos Creator Shader Effect 系列 - 4 - 老照片特效](https://www.jianshu.com/p/711a54ff2fa0)
|
||||||
* [Cocos Creator Shader Effect 系列 - 5 - 马赛克/像素化特效](https://www.jianshu.com/p/40e72ab76afd)
|
* [Cocos Creator Shader Effect 系列 - 5 - 马赛克/像素化特效](https://www.jianshu.com/p/40e72ab76afd)
|
||||||
* [Cocos Creator Shader Effect 系列 - 6 - 内发光特效](https://www.jianshu.com/p/326b73f86ecc)
|
* [Cocos Creator Shader Effect 系列 - 6 - 内发光特效](https://www.jianshu.com/p/326b73f86ecc)
|
||||||
|
* [Cocos Creator Shader Effect 系列 - 7 - 点光/扫光特效](https://www.jianshu.com/p/8ff03b34b0bd)
|
||||||
|
|
||||||
|
|
||||||
* 编写中...
|
* 编写中...
|
||||||
|
|
||||||
@@ -27,9 +29,6 @@
|
|||||||
## 三、特效预览
|
## 三、特效预览
|
||||||
|
|
||||||
|
|
||||||
### 点光(实现原理,可能在编写中,催更可到底部扫码,支持急件~🤣)(2020.01.12更新)
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### 内发光([实现原理](https://www.jianshu.com/p/326b73f86ecc))
|
### 内发光([实现原理](https://www.jianshu.com/p/326b73f86ecc))
|
||||||
|
|
||||||
@@ -47,14 +46,35 @@
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 圆角裁剪
|
### 点光([实现原理](https://www.jianshu.com/p/8ff03b34b0bd))(2020.01.12更新)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### 扫光(实现原理同点光一样,可参考[点光实现原理文章](https://www.jianshu.com/p/711a54ff2fa0))(2020.01.13更新)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### 圆角裁剪-v1(2020.01.17更新)
|
||||||
|
|
||||||
> * 声明:此特效为搬运过来的特效,非原创。
|
> * 声明:此特效为搬运过来的特效,非原创。
|
||||||
> * 修改的地方:搬运后,在原来的主要代码上加入了自己的理解注释
|
> * 修改的地方:搬运后,在原来的主要代码上加入了自己的理解注释
|
||||||
> * 实现原理:参考文章 [《圆角计算 Shader》](https://www.cnblogs.com/jqm304775992/p/4987793.html)
|
> * 实现原理:参考文章 [《圆角计算 Shader》](https://www.cnblogs.com/jqm304775992/p/4987793.html)
|
||||||
> * 参考代码:Cocos 论坛帖子[《分享更高效的 creator 裁圆角头像 shader》](https://forum.cocos.org/t/creator-shader-2019-10-22-2-2-0/82548) 和对应的 [实现代码](https://github.com/yanjifa/shaderDemo/blob/master/assets/Effect/CircleAvatar.effect)
|
> * 参考代码:Cocos 论坛帖子[《分享更高效的 creator 裁圆角头像 shader》](https://forum.cocos.org/t/creator-shader-2019-10-22-2-2-0/82548) 和对应的 [实现代码](https://github.com/yanjifa/shaderDemo/blob/master/assets/Effect/CircleAvatar.effect)
|
||||||
|
|
||||||

|
**此版本存在局限性:只有在正方形纹理上,才能裁剪出圆角,在非正方形上,无法裁剪出圆角,具体变现为有拉伸效果**
|
||||||
|
|
||||||
|
如:下面GIF中第3到5秒演示所示,黄色和红色的非正方形纹理的圆角明显被拉伸
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### 圆角裁剪-v2(2020.01.17更新)
|
||||||
|
|
||||||
|
在 **圆角裁剪-v1** 的原理基础上,新增支持任意纹理的圆角裁剪
|
||||||
|
|
||||||
|
如:下面Gif中第3到5秒演示所示,黄色和红色的非正方形纹理也能裁剪出圆角效果
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
### 外发光(完善中...)
|
### 外发光(完善中...)
|
||||||
|
|
||||||
@@ -63,7 +83,6 @@
|
|||||||
## 四、TODO
|
## 四、TODO
|
||||||
|
|
||||||
* [ ] 图像模糊
|
* [ ] 图像模糊
|
||||||
* [ ] 闪光
|
|
||||||
* [ ] 波浪
|
* [ ] 波浪
|
||||||
* [ ] 雨滴
|
* [ ] 雨滴
|
||||||
* [ ] ...
|
* [ ] ...
|
||||||
|
235
assets/effects/sprite-flash-light.effect
Normal file
235
assets/effects/sprite-flash-light.effect
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||||
|
// 闪光(光速扫过)
|
||||||
|
// 原理(和点光的很类似):
|
||||||
|
// 1. 画光束
|
||||||
|
// 2. 圆心中间高亮(透明度=1.0),边缘不亮(透明度=0.0)
|
||||||
|
// 3. 在原图像上方叠加光束
|
||||||
|
|
||||||
|
CCEffect %{
|
||||||
|
techniques:
|
||||||
|
- passes:
|
||||||
|
- vert: vs
|
||||||
|
frag: fs
|
||||||
|
blendState:
|
||||||
|
targets:
|
||||||
|
- blend: true
|
||||||
|
rasterizerState:
|
||||||
|
cullMode: none
|
||||||
|
properties:
|
||||||
|
texture: { value: white }
|
||||||
|
alphaThreshold: { value: 0.5 }
|
||||||
|
|
||||||
|
# 光束颜色
|
||||||
|
lightColor: {
|
||||||
|
value: [1.0, 1.0, 0.0, 1.0],
|
||||||
|
inspector: {
|
||||||
|
type: color,
|
||||||
|
tooltip: "光束颜色"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 光束中心点坐标
|
||||||
|
lightCenterPoint: {
|
||||||
|
value: [0.2, 0.2],
|
||||||
|
inspector: {
|
||||||
|
tooltip: "光束中心点坐标"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 光束倾斜角度
|
||||||
|
lightAngle: {
|
||||||
|
value: 36.0,
|
||||||
|
inspctor: {
|
||||||
|
tooltip: "光束倾斜角度",
|
||||||
|
range: [0.0, 1.0],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 光束宽度
|
||||||
|
lightWidth: {
|
||||||
|
value: 0.2,
|
||||||
|
inspector: {
|
||||||
|
tooltip: "光束宽度"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 启用光束渐变
|
||||||
|
enableGradient: {
|
||||||
|
value: 1.0,
|
||||||
|
inspecator: {
|
||||||
|
tooltip: "是否启用光束渐变。0:不启用,非0:启用"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 裁剪掉透明区域上的光
|
||||||
|
cropAlpha: {
|
||||||
|
value: 1.0,
|
||||||
|
inspecator: {
|
||||||
|
tooltip: "是否裁剪透明区域上的光。0:不启用,非0:启用"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 是否启用迷雾效果
|
||||||
|
enableFog: {
|
||||||
|
value: 0.0,
|
||||||
|
inspecator: {
|
||||||
|
tooltip: "是否启用迷雾效果。0:不启用,非0:启用"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}%
|
||||||
|
|
||||||
|
|
||||||
|
CCProgram vs %{
|
||||||
|
precision highp float;
|
||||||
|
|
||||||
|
#include <cc-global>
|
||||||
|
#include <cc-local>
|
||||||
|
|
||||||
|
in vec3 a_position;
|
||||||
|
in vec4 a_color;
|
||||||
|
out vec4 v_color;
|
||||||
|
|
||||||
|
#if USE_TEXTURE
|
||||||
|
in vec2 a_uv0;
|
||||||
|
out vec2 v_uv0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void main () {
|
||||||
|
vec4 pos = vec4(a_position, 1);
|
||||||
|
|
||||||
|
#if CC_USE_MODEL
|
||||||
|
pos = cc_matViewProj * cc_matWorld * pos;
|
||||||
|
#else
|
||||||
|
pos = cc_matViewProj * pos;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if USE_TEXTURE
|
||||||
|
v_uv0 = a_uv0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
v_color = a_color;
|
||||||
|
|
||||||
|
gl_Position = pos;
|
||||||
|
}
|
||||||
|
}%
|
||||||
|
|
||||||
|
|
||||||
|
CCProgram fs %{
|
||||||
|
precision highp float;
|
||||||
|
|
||||||
|
#include <alpha-test>
|
||||||
|
|
||||||
|
in vec4 v_color;
|
||||||
|
|
||||||
|
#if USE_TEXTURE
|
||||||
|
in vec2 v_uv0;
|
||||||
|
uniform sampler2D texture;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ENABLE_LIGHT
|
||||||
|
uniform Light {
|
||||||
|
// 光束颜色
|
||||||
|
vec4 lightColor;
|
||||||
|
|
||||||
|
// 光束中心点坐标
|
||||||
|
vec2 lightCenterPoint;
|
||||||
|
|
||||||
|
// 光束倾斜角度
|
||||||
|
float lightAngle;
|
||||||
|
|
||||||
|
// 光束宽度
|
||||||
|
float lightWidth;
|
||||||
|
|
||||||
|
// 启用光束渐变
|
||||||
|
// ps:编辑器还不支持 bool 类型的样子,因此用float来定义
|
||||||
|
float enableGradient;
|
||||||
|
|
||||||
|
// 裁剪掉透明区域上的光
|
||||||
|
// ps:编辑器还不支持 bool 类型的样子,因此用float来定义
|
||||||
|
float cropAlpha;
|
||||||
|
|
||||||
|
// 是否启用迷雾效果
|
||||||
|
// ps:编辑器还不支持 bool 类型的样子,因此用float来定义
|
||||||
|
float enableFog;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加光束颜色
|
||||||
|
*/
|
||||||
|
vec4 addLightColor(vec4 textureColor, vec4 lightColor, vec2 lightCenterPoint, float lightAngle, float lightWidth) {
|
||||||
|
// 边界值处理,没有宽度就返回原始颜色
|
||||||
|
if (lightWidth <= 0.0) {
|
||||||
|
return textureColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算当前 uv 到 光束 的距离
|
||||||
|
float angleInRadians = radians(lightAngle);
|
||||||
|
|
||||||
|
// 角度0与非0不同处理
|
||||||
|
float dis = 0.0;
|
||||||
|
if (mod(lightAngle, 180.0) != 0.0) {
|
||||||
|
// 计算光束中心线下方与X轴交点的X坐标
|
||||||
|
// 1.0 - lightCenterPoint.y 是将转换为OpenGL坐标系,下文的 1.0 - y 类似
|
||||||
|
float lightOffsetX = lightCenterPoint.x - ((1.0 - lightCenterPoint.y) / tan(angleInRadians));
|
||||||
|
|
||||||
|
// 以当前点画一条平行于X轴的线,假设此线和光束中心线相交的点为D点
|
||||||
|
// 那么
|
||||||
|
// D.y = uv0.y
|
||||||
|
// D.x = lightOffsetX + D.y / tan(angle)
|
||||||
|
float dx = lightOffsetX + (1.0 - v_uv0.y) / tan(angleInRadians);
|
||||||
|
|
||||||
|
// D 到当前 uv0 的距离就是
|
||||||
|
// dis = |uv0.x - D.x|
|
||||||
|
float offsetDis = abs(v_uv0.x - dx);
|
||||||
|
|
||||||
|
// 当前点到光束中心线的的垂直距离就好算了
|
||||||
|
dis = sin(angleInRadians) * offsetDis;
|
||||||
|
} else {
|
||||||
|
dis = abs(v_uv0.y - lightCenterPoint.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
float a = 1.0 ;
|
||||||
|
// 裁剪掉透明区域上的点光
|
||||||
|
if (bool(cropAlpha)) {
|
||||||
|
a *= step(0.01, textureColor.a);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 裁剪掉光束范围外的uv(迷雾效果)
|
||||||
|
if (!bool(enableFog)) {
|
||||||
|
a *= step(dis, lightWidth * 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加入从中心往外渐变的效果
|
||||||
|
if (bool(enableGradient)) {
|
||||||
|
a *= 1.0 - dis / (lightWidth * 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算出扩散范围内,不同 uv 对应的实际扩散颜色值
|
||||||
|
vec4 finalLightColor = lightColor * a;
|
||||||
|
|
||||||
|
// 混合颜色:在原始图像颜色上叠加扩散颜色
|
||||||
|
return textureColor * textureColor.a + finalLightColor;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void main () {
|
||||||
|
vec4 o = vec4(1, 1, 1, 1);
|
||||||
|
|
||||||
|
#if USE_TEXTURE
|
||||||
|
o *= texture(texture, v_uv0);
|
||||||
|
#if CC_USE_ALPHA_ATLAS_TEXTURE
|
||||||
|
o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
o *= v_color;
|
||||||
|
|
||||||
|
ALPHA_TEST(o);
|
||||||
|
|
||||||
|
gl_FragColor = o;
|
||||||
|
|
||||||
|
#if ENABLE_LIGHT
|
||||||
|
gl_FragColor = addLightColor(gl_FragColor, lightColor, lightCenterPoint, lightAngle, lightWidth);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}%
|
17
assets/effects/sprite-flash-light.effect.meta
Normal file
17
assets/effects/sprite-flash-light.effect.meta
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.23",
|
||||||
|
"uuid": "e9682cd1-a19c-4fcb-ad8c-cf1783b805e6",
|
||||||
|
"compiledShaders": [
|
||||||
|
{
|
||||||
|
"glsl1": {
|
||||||
|
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\n\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n",
|
||||||
|
"frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform float alphaThreshold;\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\n#if ENABLE_LIGHT\nuniform vec4 lightColor;\nuniform vec2 lightCenterPoint;\nuniform float lightAngle;\nuniform float lightWidth;\nuniform float enableGradient;\nuniform float cropAlpha;\nuniform float enableFog;\n/**\n * 添加光束颜色\n */\nvec4 addLightColor(vec4 textureColor, vec4 lightColor, vec2 lightCenterPoint, float lightAngle, float lightWidth) {\n\n if (lightWidth <= 0.0) {\n return textureColor;\n }\n\n float angleInRadians = radians(lightAngle);\n\n float dis = 0.0;\n if (mod(lightAngle, 180.0) != 0.0) {\n\n float lightOffsetX = lightCenterPoint.x - ((1.0 - lightCenterPoint.y) / tan(angleInRadians));\n\n float dx = lightOffsetX + (1.0 - v_uv0.y) / tan(angleInRadians);\n\n float offsetDis = abs(v_uv0.x - dx);\n\n dis = sin(angleInRadians) * offsetDis;\n } else {\n dis = abs(v_uv0.y - lightCenterPoint.y);\n }\n \n float a = 1.0 ;\n\n if (bool(cropAlpha)) {\n a *= step(0.01, textureColor.a);\n }\n\n if (!bool(enableFog)) {\n a *= step(dis, lightWidth * 0.5);\n }\n\n if (bool(enableGradient)) {\n a *= 1.0 - dis / (lightWidth * 0.5);\n }\n\n vec4 finalLightColor = lightColor * a;\n\n return textureColor * textureColor.a + finalLightColor;\n}\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n gl_FragColor = o;\n \n #if ENABLE_LIGHT\n gl_FragColor = addLightColor(gl_FragColor, lightColor, lightCenterPoint, lightAngle, lightWidth);\n #endif\n}\n"
|
||||||
|
},
|
||||||
|
"glsl3": {
|
||||||
|
"vert": "\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time;\n\n vec4 cc_screenSize;\n\n vec4 cc_screenScale;\n\n vec4 cc_nativeSize;\n\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n\n vec4 cc_exposure;\n\n vec4 cc_mainLitDir;\n\n vec4 cc_mainLitColor;\n\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\n\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n",
|
||||||
|
"frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform ALPHA_TEST {\n float alphaThreshold;\n }\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nin vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\n#if ENABLE_LIGHT\nuniform Light {\n\n vec4 lightColor;\n\n vec2 lightCenterPoint;\n\n float lightAngle;\n\n float lightWidth;\n\n float enableGradient;\n\n float cropAlpha;\n\n float enableFog;\n}\n\n/**\n * 添加光束颜色\n */\nvec4 addLightColor(vec4 textureColor, vec4 lightColor, vec2 lightCenterPoint, float lightAngle, float lightWidth) {\n\n if (lightWidth <= 0.0) {\n return textureColor;\n }\n\n float angleInRadians = radians(lightAngle);\n\n float dis = 0.0;\n if (mod(lightAngle, 180.0) != 0.0) {\n\n float lightOffsetX = lightCenterPoint.x - ((1.0 - lightCenterPoint.y) / tan(angleInRadians));\n\n float dx = lightOffsetX + (1.0 - v_uv0.y) / tan(angleInRadians);\n\n float offsetDis = abs(v_uv0.x - dx);\n\n dis = sin(angleInRadians) * offsetDis;\n } else {\n dis = abs(v_uv0.y - lightCenterPoint.y);\n }\n \n float a = 1.0 ;\n\n if (bool(cropAlpha)) {\n a *= step(0.01, textureColor.a);\n }\n\n if (!bool(enableFog)) {\n a *= step(dis, lightWidth * 0.5);\n }\n\n if (bool(enableGradient)) {\n a *= 1.0 - dis / (lightWidth * 0.5);\n }\n\n vec4 finalLightColor = lightColor * a;\n\n return textureColor * textureColor.a + finalLightColor;\n}\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n gl_FragColor = o;\n \n #if ENABLE_LIGHT\n gl_FragColor = addLightColor(gl_FragColor, lightColor, lightCenterPoint, lightAngle, lightWidth);\n #endif\n}\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
@@ -116,8 +116,8 @@ CCProgram fs %{
|
|||||||
/**
|
/**
|
||||||
* 添加某个扩散点后混合后的纹理颜色
|
* 添加某个扩散点后混合后的纹理颜色
|
||||||
*/
|
*/
|
||||||
vec4 addDiffusionColor(vec4 textureColor, vec2 centerPoint, float radius, vec4 centerColor) {
|
vec4 addLightColor(vec4 textureColor, vec2 centerPoint, float radius, vec4 centerColor) {
|
||||||
// 计算当前 uv 到扩散起点的距离
|
// 计算当前 uv 到圆心起点的距离
|
||||||
float dis = distance(v_uv0, centerPoint);
|
float dis = distance(v_uv0, centerPoint);
|
||||||
|
|
||||||
float a = 1.0 ;
|
float a = 1.0 ;
|
||||||
@@ -127,7 +127,7 @@ CCProgram fs %{
|
|||||||
a *= step(0.01, textureColor.a);
|
a *= step(0.01, textureColor.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 裁剪掉扩散范围外的uv(迷雾效果)
|
// 裁剪掉圆范围外的uv(迷雾效果)
|
||||||
if (!enableFog) {
|
if (!enableFog) {
|
||||||
a *= step(dis, radius);
|
a *= step(dis, radius);
|
||||||
}
|
}
|
||||||
@@ -135,15 +135,11 @@ CCProgram fs %{
|
|||||||
// 加入从中心往外渐变的效果
|
// 加入从中心往外渐变的效果
|
||||||
a *= 1.0 - (dis / radius);
|
a *= 1.0 - (dis / radius);
|
||||||
|
|
||||||
// 加点料,让中心点更加亮
|
// 计算出圆范围内,不同 uv 对应的实际颜色值
|
||||||
// a = -1.0 * (a - 1.0) * (a - 1.0) + 1.0;
|
vec4 lightColor = centerColor * a;
|
||||||
// a = -1.0 * (a - 1.0) * (a - 1.0) * (a - 1.0) * (a - 1.0) + 1.0;
|
|
||||||
|
|
||||||
// 计算出扩散范围内,不同 uv 对应的实际扩散颜色值
|
// 混合颜色:在原始图像颜色上叠加圆颜色
|
||||||
vec4 diffusionColor = centerColor * a;
|
return textureColor * textureColor.a + lightColor;
|
||||||
|
|
||||||
// 混合颜色:在原始图像颜色上叠加扩散颜色
|
|
||||||
return textureColor * textureColor.a + diffusionColor;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -164,7 +160,7 @@ CCProgram fs %{
|
|||||||
gl_FragColor = o;
|
gl_FragColor = o;
|
||||||
|
|
||||||
#if ENABLE_DIFFUSION
|
#if ENABLE_DIFFUSION
|
||||||
gl_FragColor = addDiffusionColor(gl_FragColor, centerPoint, radius, centerColor);
|
gl_FragColor = addLightColor(gl_FragColor, centerPoint, radius, centerColor);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}%
|
}%
|
||||||
|
@@ -5,11 +5,11 @@
|
|||||||
{
|
{
|
||||||
"glsl1": {
|
"glsl1": {
|
||||||
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\n\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n",
|
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\n\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n",
|
||||||
"frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform float alphaThreshold;\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\n#if ENABLE_DIFFUSION\nuniform vec4 centerColor;\nuniform vec2 centerPoint;\nuniform float radius;\nuniform bool cropAlpha;\nuniform bool enableFog;\n/**\n * 添加某个扩散点后混合后的纹理颜色\n */\nvec4 addDiffusionColor(vec4 textureColor, vec2 centerPoint, float radius, vec4 centerColor) {\n\n float dis = distance(v_uv0, centerPoint);\n\n float a = 1.0 ;\n\n if (cropAlpha) {\n a *= step(0.01, textureColor.a);\n }\n\n if (!enableFog) {\n a *= step(dis, radius);\n }\n\n a *= 1.0 - (dis / radius);\n\n vec4 diffusionColor = centerColor * a;\n\n return textureColor * textureColor.a + diffusionColor;\n}\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n gl_FragColor = o;\n \n #if ENABLE_DIFFUSION\n gl_FragColor = addDiffusionColor(gl_FragColor, centerPoint, radius, centerColor);\n #endif\n}\n"
|
"frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform float alphaThreshold;\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\n#if ENABLE_DIFFUSION\nuniform vec4 centerColor;\nuniform vec2 centerPoint;\nuniform float radius;\nuniform bool cropAlpha;\nuniform bool enableFog;\n/**\n * 添加某个扩散点后混合后的纹理颜色\n */\nvec4 addLightColor(vec4 textureColor, vec2 centerPoint, float radius, vec4 centerColor) {\n\n float dis = distance(v_uv0, centerPoint);\n\n float a = 1.0 ;\n\n if (cropAlpha) {\n a *= step(0.01, textureColor.a);\n }\n\n if (!enableFog) {\n a *= step(dis, radius);\n }\n\n a *= 1.0 - (dis / radius);\n\n vec4 lightColor = centerColor * a;\n\n return textureColor * textureColor.a + lightColor;\n}\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n gl_FragColor = o;\n \n #if ENABLE_DIFFUSION\n gl_FragColor = addLightColor(gl_FragColor, centerPoint, radius, centerColor);\n #endif\n}\n"
|
||||||
},
|
},
|
||||||
"glsl3": {
|
"glsl3": {
|
||||||
"vert": "\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time;\n\n vec4 cc_screenSize;\n\n vec4 cc_screenScale;\n\n vec4 cc_nativeSize;\n\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n\n vec4 cc_exposure;\n\n vec4 cc_mainLitDir;\n\n vec4 cc_mainLitColor;\n\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\n\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n",
|
"vert": "\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time;\n\n vec4 cc_screenSize;\n\n vec4 cc_screenScale;\n\n vec4 cc_nativeSize;\n\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n\n vec4 cc_exposure;\n\n vec4 cc_mainLitDir;\n\n vec4 cc_mainLitColor;\n\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\n\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n",
|
||||||
"frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform ALPHA_TEST {\n float alphaThreshold;\n }\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nin vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\n#if ENABLE_DIFFUSION\nuniform Diffusion {\n\n vec4 centerColor;\n\n vec2 centerPoint;\n\n float radius;\n\n bool cropAlpha;\n\n bool enableFog;\n}\n\n/**\n * 添加某个扩散点后混合后的纹理颜色\n */\nvec4 addDiffusionColor(vec4 textureColor, vec2 centerPoint, float radius, vec4 centerColor) {\n\n float dis = distance(v_uv0, centerPoint);\n\n float a = 1.0 ;\n\n if (cropAlpha) {\n a *= step(0.01, textureColor.a);\n }\n\n if (!enableFog) {\n a *= step(dis, radius);\n }\n\n a *= 1.0 - (dis / radius);\n\n vec4 diffusionColor = centerColor * a;\n\n return textureColor * textureColor.a + diffusionColor;\n}\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n gl_FragColor = o;\n \n #if ENABLE_DIFFUSION\n gl_FragColor = addDiffusionColor(gl_FragColor, centerPoint, radius, centerColor);\n #endif\n}\n"
|
"frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform ALPHA_TEST {\n float alphaThreshold;\n }\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nin vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\n#if ENABLE_DIFFUSION\nuniform Diffusion {\n\n vec4 centerColor;\n\n vec2 centerPoint;\n\n float radius;\n\n bool cropAlpha;\n\n bool enableFog;\n}\n\n/**\n * 添加某个扩散点后混合后的纹理颜色\n */\nvec4 addLightColor(vec4 textureColor, vec2 centerPoint, float radius, vec4 centerColor) {\n\n float dis = distance(v_uv0, centerPoint);\n\n float a = 1.0 ;\n\n if (cropAlpha) {\n a *= step(0.01, textureColor.a);\n }\n\n if (!enableFog) {\n a *= step(dis, radius);\n }\n\n a *= 1.0 - (dis / radius);\n\n vec4 lightColor = centerColor * a;\n\n return textureColor * textureColor.a + lightColor;\n}\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n gl_FragColor = o;\n \n #if ENABLE_DIFFUSION\n gl_FragColor = addLightColor(gl_FragColor, centerPoint, radius, centerColor);\n #endif\n}\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||||
// 圆角裁剪
|
//
|
||||||
|
// 圆角裁剪(仅支持正方形纹理)
|
||||||
|
//
|
||||||
// 原理:https://www.cnblogs.com/jqm304775992/p/4987793.html
|
// 原理:https://www.cnblogs.com/jqm304775992/p/4987793.html
|
||||||
// 代码:复制 yanjifa/shaderDemor 的 https://github.com/yanjifa/shaderDemo/blob/master/assets/Effect/CircleAvatar.effect
|
// 代码:复制 yanjifa/shaderDemor 的 https://github.com/yanjifa/shaderDemo/blob/master/assets/Effect/CircleAvatar.effect
|
||||||
|
|
||||||
@@ -17,8 +19,8 @@ CCEffect %{
|
|||||||
texture: { value: white }
|
texture: { value: white }
|
||||||
alphaThreshold: { value: 0.5 }
|
alphaThreshold: { value: 0.5 }
|
||||||
# 圆角半径
|
# 圆角半径
|
||||||
roundCornerRadius: {
|
radius: {
|
||||||
value: 0.1,
|
value: 0.4,
|
||||||
inspector: {
|
inspector: {
|
||||||
tooltip: "圆角半径",
|
tooltip: "圆角半径",
|
||||||
range: [0.0, 0.5]
|
range: [0.0, 0.5]
|
||||||
@@ -77,7 +79,7 @@ CCProgram fs %{
|
|||||||
#if ENABLE_ROUNDCORNER
|
#if ENABLE_ROUNDCORNER
|
||||||
uniform RoundCorner {
|
uniform RoundCorner {
|
||||||
// 圆角半径
|
// 圆角半径
|
||||||
float roundCornerRadius;
|
float radius;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -97,17 +99,17 @@ CCProgram fs %{
|
|||||||
|
|
||||||
#if ENABLE_ROUNDCORNER
|
#if ENABLE_ROUNDCORNER
|
||||||
// 约束圆角半径范围在 [0.0, 0.5]
|
// 约束圆角半径范围在 [0.0, 0.5]
|
||||||
float radius = clamp(0.0, 0.5, roundCornerRadius);
|
float circleRadius = clamp(0.0, 0.5, radius);
|
||||||
|
|
||||||
// 将纹理uv往左下偏移,实现偏移后的纹理中心点在 OpenGL 坐标系的原点
|
// 将纹理uv往左上偏移,实现偏移后的坐标系原点在纹理中心
|
||||||
vec2 uv = v_uv0.xy - vec2(0.5, 0.5);
|
vec2 uv = v_uv0.xy - vec2(0.5, 0.5);
|
||||||
|
|
||||||
// uv.x , uv.y : 为偏移后的的uv
|
// uv.x , uv.y : 为偏移后的的uv
|
||||||
// abs(uv.x) , abs(uv.y) : 将第二、三、四象限的点都投影到第一象限上,这样子只需要处理第一象限的情况就可以,简化判断
|
// abs(uv.x) , abs(uv.y) : 将第二、三、四象限的点都投影到第一象限上,这样子只需要处理第一象限的情况就可以,简化判断
|
||||||
// 0.5 - radius : 计算出第一象限的圆角所在圆的圆心坐标
|
// 0.5 - radius : 计算出第一象限的圆角所在圆的圆心坐标
|
||||||
// (rx, ry) : 偏移映射后的 新的uv 坐标,相对于 第一象限圆角坐在圆心坐标 的相对坐标
|
// (rx, ry) : 偏移映射后的 新的uv 坐标,相对于 第一象限圆角坐在圆心坐标 的相对坐标
|
||||||
float rx = abs(uv.x) - (0.5 - radius);
|
float rx = abs(uv.x) - (0.5 - circleRadius);
|
||||||
float ry = abs(uv.y) - (0.5 - radius);
|
float ry = abs(uv.y) - (0.5 - circleRadius);
|
||||||
|
|
||||||
// 区分 以第一象限圆角所在圆心坐标为原点的坐标的四个象限
|
// 区分 以第一象限圆角所在圆心坐标为原点的坐标的四个象限
|
||||||
//
|
//
|
||||||
@@ -117,26 +119,26 @@ CCProgram fs %{
|
|||||||
// 第四象限 mx = 1, my = 0
|
// 第四象限 mx = 1, my = 0
|
||||||
//
|
//
|
||||||
// 当 mx * my 时,只要等于1,那就是标识第一象限(实际对应圆角区域所在矩形),否则就是第二、三、四象限
|
// 当 mx * my 时,只要等于1,那就是标识第一象限(实际对应圆角区域所在矩形),否则就是第二、三、四象限
|
||||||
float mx = step(0.5 - radius, abs(uv.x));
|
float mx = step(0.5 - circleRadius, abs(uv.x));
|
||||||
float my = step(0.5 - radius, abs(uv.y));
|
float my = step(0.5 - circleRadius, abs(uv.y));
|
||||||
|
|
||||||
// 计算相对uv坐标到圆心的距离
|
// 计算相对uv坐标到圆心的距离
|
||||||
float len = length(vec2(rx, ry));
|
float len = length(vec2(rx, ry));
|
||||||
|
|
||||||
// mx * my = 0 时,代表非圆角区域,a 值为1,代表完全采用原始纹理的透明度
|
// mx * my = 0 时,代表非圆角区域,a 值为1,代表完全采用原始纹理的透明度
|
||||||
// mx * my = 1 时,代表园所所在矩形区域
|
// mx * my = 1 时,代表园所所在矩形区域
|
||||||
// step(radius, len) 可以区分出圆角所在矩形区域的 圆角区域 和 非圆角区域
|
// step(circleRadius, len) 可以区分出圆角所在矩形区域的 圆角区域 和 非圆角区域
|
||||||
// 其中圆角区域值为0,非圆角区域值为1
|
// 其中圆角区域值为0,非圆角区域值为1
|
||||||
// 当为圆角区域时,a 值为1,代表完全采用原始纹理透明度
|
// 当为圆角区域时,a 值为1,代表完全采用原始纹理透明度
|
||||||
// 当为非圆角区域时,a 值为0,代表完全透明
|
// 当为非圆角区域时,a 值为0,代表完全透明
|
||||||
// 至此已经实现圆角裁剪
|
// 至此已经实现圆角裁剪
|
||||||
//
|
//
|
||||||
// smoothstep(0., radius * 0.01, len - radius) 是用于抗锯齿优化
|
// smoothstep(0., circleRadius * 0.01, len - circleRadius) 是用于抗锯齿优化
|
||||||
// 原理:针对点在非圆角区域的情况,针对点在大于「圆半径一点点」地方的区域,进行平滑过渡,以实现抗锯齿
|
// 原理:针对点在非圆角区域的情况,针对点在大于「圆半径一点点」地方的区域,进行平滑过渡,以实现抗锯齿
|
||||||
// 其中,
|
// 其中,
|
||||||
// 「圆半径一点点」用 radius * 0.01 表示(0.01 可自行改变)
|
// 「圆半径一点点」用 circleRadius * 0.01 表示(0.01 可自行改变)
|
||||||
// 点在大于圆半径的区域用 len - radius ,此值会在 [0.0, radius * 0.01] 之间时会平滑过渡
|
// 点在大于圆半径的区域用 len - circleRadius ,此值会在 [0.0, circleRadius * 0.01] 之间时会平滑过渡
|
||||||
float a = 1.0 - mx * my * step(radius, len) * smoothstep(0., radius * 0.01, len - radius);
|
float a = 1.0 - mx * my * step(circleRadius, len) * smoothstep(0., circleRadius * 0.01, len - circleRadius);
|
||||||
o = vec4(o.rgb, o.a * a);
|
o = vec4(o.rgb, o.a * a);
|
||||||
#endif
|
#endif
|
||||||
gl_FragColor = o;
|
gl_FragColor = o;
|
@@ -5,11 +5,11 @@
|
|||||||
{
|
{
|
||||||
"glsl1": {
|
"glsl1": {
|
||||||
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\n\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n",
|
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\n\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n",
|
||||||
"frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform float alphaThreshold;\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\n#if ENABLE_ROUNDCORNER\nuniform float roundCornerRadius;\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n #if ENABLE_ROUNDCORNER\n\n float radius = clamp(0.0, 0.5, roundCornerRadius);\n\n vec2 uv = v_uv0.xy - vec2(0.5, 0.5);\n\n float rx = abs(uv.x) - (0.5 - radius);\n float ry = abs(uv.y) - (0.5 - radius);\n\n float mx = step(0.5 - radius, abs(uv.x));\n float my = step(0.5 - radius, abs(uv.y));\n\n float len = length(vec2(rx, ry));\n\n float a = 1.0 - mx * my * step(radius, len) * smoothstep(0., radius * 0.01, len - radius);\n o = vec4(o.rgb, o.a * a);\n #endif\n gl_FragColor = o;\n}\n"
|
"frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform float alphaThreshold;\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\n#if ENABLE_ROUNDCORNER\nuniform float radius;\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n #if ENABLE_ROUNDCORNER\n\n float circleRadius = clamp(0.0, 0.5, radius);\n\n vec2 uv = v_uv0.xy - vec2(0.5, 0.5);\n\n float rx = abs(uv.x) - (0.5 - circleRadius);\n float ry = abs(uv.y) - (0.5 - circleRadius);\n\n float mx = step(0.5 - circleRadius, abs(uv.x));\n float my = step(0.5 - circleRadius, abs(uv.y));\n\n float len = length(vec2(rx, ry));\n\n float a = 1.0 - mx * my * step(circleRadius, len) * smoothstep(0., circleRadius * 0.01, len - circleRadius);\n o = vec4(o.rgb, o.a * a);\n #endif\n gl_FragColor = o;\n}\n"
|
||||||
},
|
},
|
||||||
"glsl3": {
|
"glsl3": {
|
||||||
"vert": "\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time;\n\n vec4 cc_screenSize;\n\n vec4 cc_screenScale;\n\n vec4 cc_nativeSize;\n\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n\n vec4 cc_exposure;\n\n vec4 cc_mainLitDir;\n\n vec4 cc_mainLitColor;\n\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\n\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n",
|
"vert": "\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time;\n\n vec4 cc_screenSize;\n\n vec4 cc_screenScale;\n\n vec4 cc_nativeSize;\n\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n\n vec4 cc_exposure;\n\n vec4 cc_mainLitDir;\n\n vec4 cc_mainLitColor;\n\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\n\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n",
|
||||||
"frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform ALPHA_TEST {\n float alphaThreshold;\n }\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nin vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\n#if ENABLE_ROUNDCORNER\nuniform RoundCorner {\n\n float roundCornerRadius;\n}\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n #if ENABLE_ROUNDCORNER\n\n float radius = clamp(0.0, 0.5, roundCornerRadius);\n\n vec2 uv = v_uv0.xy - vec2(0.5, 0.5);\n\n float rx = abs(uv.x) - (0.5 - radius);\n float ry = abs(uv.y) - (0.5 - radius);\n\n float mx = step(0.5 - radius, abs(uv.x));\n float my = step(0.5 - radius, abs(uv.y));\n\n float len = length(vec2(rx, ry));\n\n float a = 1.0 - mx * my * step(radius, len) * smoothstep(0., radius * 0.01, len - radius);\n o = vec4(o.rgb, o.a * a);\n #endif\n gl_FragColor = o;\n}\n"
|
"frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform ALPHA_TEST {\n float alphaThreshold;\n }\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nin vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\n#if ENABLE_ROUNDCORNER\nuniform RoundCorner {\n\n float radius;\n}\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n #if ENABLE_ROUNDCORNER\n\n float circleRadius = clamp(0.0, 0.5, radius);\n\n vec2 uv = v_uv0.xy - vec2(0.5, 0.5);\n\n float rx = abs(uv.x) - (0.5 - circleRadius);\n float ry = abs(uv.y) - (0.5 - circleRadius);\n\n float mx = step(0.5 - circleRadius, abs(uv.x));\n float my = step(0.5 - circleRadius, abs(uv.y));\n\n float len = length(vec2(rx, ry));\n\n float a = 1.0 - mx * my * step(circleRadius, len) * smoothstep(0., circleRadius * 0.01, len - circleRadius);\n o = vec4(o.rgb, o.a * a);\n #endif\n gl_FragColor = o;\n}\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
194
assets/effects/sprite-round-corner-crop-v2.effect
Normal file
194
assets/effects/sprite-round-corner-crop-v2.effect
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||||
|
//
|
||||||
|
// 圆角裁剪(支持任意宽高纹理)
|
||||||
|
//
|
||||||
|
// 原理:
|
||||||
|
// 1. 正方形纹理的圆角原理参考 https://www.cnblogs.com/jqm304775992/p/4987793.html
|
||||||
|
// 2. 正方形纹理的圆角代码参考 yanjifa/shaderDemor 的 https://github.com/yanjifa/shaderDemo/blob/master/assets/Effect/CircleAvatar.effect
|
||||||
|
// 3. 上述皆为只针对正方形纹理做的操作,如果是长方形的纹理,那么圆角就会有拉伸后的效果,最后变成看起来就不是圆角了,本特效支持任意长方形做圆角
|
||||||
|
|
||||||
|
CCEffect %{
|
||||||
|
techniques:
|
||||||
|
- passes:
|
||||||
|
- vert: vs
|
||||||
|
frag: fs
|
||||||
|
blendState:
|
||||||
|
targets:
|
||||||
|
- blend: true
|
||||||
|
rasterizerState:
|
||||||
|
cullMode: none
|
||||||
|
properties:
|
||||||
|
texture: { value: white }
|
||||||
|
alphaThreshold: { value: 0.5 }
|
||||||
|
|
||||||
|
# 圆角x轴半径长度(相对于纹理宽度)
|
||||||
|
xRadius: {
|
||||||
|
value: 0.4,
|
||||||
|
inspector: {
|
||||||
|
tooltip: "圆角x轴半径长度(相对于纹理宽度)",
|
||||||
|
range: [0.0, 0.5]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 圆角y轴半径长度(相对于纹理高度)
|
||||||
|
yRadius: {
|
||||||
|
value: 0.4,
|
||||||
|
inspector: {
|
||||||
|
tooltip: "圆角y轴半径长度(相对于纹理高度)",
|
||||||
|
range: [0.0, 0.5]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}%
|
||||||
|
|
||||||
|
|
||||||
|
CCProgram vs %{
|
||||||
|
precision highp float;
|
||||||
|
|
||||||
|
#include <cc-global>
|
||||||
|
#include <cc-local>
|
||||||
|
|
||||||
|
in vec3 a_position;
|
||||||
|
in vec4 a_color;
|
||||||
|
out vec4 v_color;
|
||||||
|
|
||||||
|
#if USE_TEXTURE
|
||||||
|
in vec2 a_uv0;
|
||||||
|
out vec2 v_uv0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void main () {
|
||||||
|
vec4 pos = vec4(a_position, 1);
|
||||||
|
|
||||||
|
#if CC_USE_MODEL
|
||||||
|
pos = cc_matViewProj * cc_matWorld * pos;
|
||||||
|
#else
|
||||||
|
pos = cc_matViewProj * pos;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if USE_TEXTURE
|
||||||
|
v_uv0 = a_uv0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
v_color = a_color;
|
||||||
|
|
||||||
|
gl_Position = pos;
|
||||||
|
}
|
||||||
|
}%
|
||||||
|
|
||||||
|
|
||||||
|
CCProgram fs %{
|
||||||
|
precision highp float;
|
||||||
|
|
||||||
|
#include <alpha-test>
|
||||||
|
|
||||||
|
in vec4 v_color;
|
||||||
|
|
||||||
|
#if USE_TEXTURE
|
||||||
|
in vec2 v_uv0;
|
||||||
|
uniform sampler2D texture;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ENABLE_ROUNDCORNER
|
||||||
|
uniform RoundCorner {
|
||||||
|
// 圆角x轴半径长度(相对于纹理宽度)
|
||||||
|
float xRadius;
|
||||||
|
|
||||||
|
// 圆角y轴半径长度(相对于纹理高度)
|
||||||
|
float yRadius;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void main () {
|
||||||
|
vec4 o = vec4(1, 1, 1, 1);
|
||||||
|
|
||||||
|
#if USE_TEXTURE
|
||||||
|
o *= texture(texture, v_uv0);
|
||||||
|
#if CC_USE_ALPHA_ATLAS_TEXTURE
|
||||||
|
o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
o *= v_color;
|
||||||
|
|
||||||
|
ALPHA_TEST(o);
|
||||||
|
|
||||||
|
#if ENABLE_ROUNDCORNER
|
||||||
|
|
||||||
|
// 约束圆角半径范围在 [0.0, 0.5]
|
||||||
|
//
|
||||||
|
// 请注意这里我是用椭圆前缀去命名的半径
|
||||||
|
//
|
||||||
|
// 为什么是椭圆?
|
||||||
|
//
|
||||||
|
// 因为圆角,相对于长方形的纹理的宽高来说,归一化后值并不一样,不是圆,而是一个椭圆
|
||||||
|
//
|
||||||
|
// 比如:
|
||||||
|
//
|
||||||
|
// 纹理是 200 x 100 的像素,圆角半径是20像素,那么归一化后
|
||||||
|
// X轴上的半径就是 20 / 200 = 0.1
|
||||||
|
// Y轴上的半径就是 20 / 100 = 0.2
|
||||||
|
//
|
||||||
|
// 这就会变成是椭圆,而不是圆
|
||||||
|
float ellipseXRadius = clamp(0.0, 0.5, xRadius);
|
||||||
|
float ellipseYRadius = clamp(0.0, 0.5, yRadius);
|
||||||
|
|
||||||
|
// 将纹理uv往左上偏移,实现偏移后的坐标系原点在纹理中心
|
||||||
|
vec2 uv = v_uv0.xy - vec2(0.5, 0.5);
|
||||||
|
|
||||||
|
// uv.x , uv.y : 为偏移后的的uv
|
||||||
|
// abs(uv.x) , abs(uv.y) : 将第二、三、四象限的点都投影到第一象限上,这样子只需要处理第一象限的情况就可以,简化判断
|
||||||
|
// 0.5 - radius : 计算出第一象限的圆角所在圆的圆心坐标
|
||||||
|
// (rx, ry) : 偏移映射后的 新的uv 坐标,相对于 第一象限圆角坐在圆心坐标 的相对坐标
|
||||||
|
float rx = abs(uv.x) - (0.5 - ellipseXRadius);
|
||||||
|
float ry = abs(uv.y) - (0.5 - ellipseYRadius);
|
||||||
|
|
||||||
|
// 区分 以第一象限圆角所在圆心坐标为原点的坐标的四个象限
|
||||||
|
//
|
||||||
|
// 第一象限 mx = 1, my = 1
|
||||||
|
// 第二象限 mx = 0, my = 1
|
||||||
|
// 第三象限 mx = 0, my = 0
|
||||||
|
// 第四象限 mx = 1, my = 0
|
||||||
|
//
|
||||||
|
// 当 mx * my 时,只要等于1,那就是标识第一象限(实际对应圆角区域所在矩形),否则就是第二、三、四象限
|
||||||
|
float mx = step(0.5 - ellipseXRadius, abs(uv.x));
|
||||||
|
float my = step(0.5 - ellipseYRadius, abs(uv.y));
|
||||||
|
|
||||||
|
// 判断点(rx, ry)是否在椭圆外部(应用椭圆公式)
|
||||||
|
float isOutOfEllipse = step(1.0, pow(rx, 2.0) / pow(xRadius, 2.0) + pow(ry, 2.0) / pow(yRadius, 2.0));
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 抗锯齿
|
||||||
|
// 1. 先计算当前点到椭圆中心的角度
|
||||||
|
float angleInRadian = atan(ry / rx);
|
||||||
|
|
||||||
|
// 2. 计算这个角度下,对于对应圆角(椭圆)上的点
|
||||||
|
vec2 pointInEllipse = vec2(xRadius * cos(angleInRadian), yRadius * sin(angleInRadian));
|
||||||
|
|
||||||
|
// 3. 计算这个角度下,比当前圆角大一点椭圆上的点
|
||||||
|
vec2 pointInBigEllipse = vec2((xRadius * 1.01) * cos(angleInRadian), (yRadius * 1.01)* sin(angleInRadian));
|
||||||
|
|
||||||
|
// 4. 计算最远点到当前椭圆的距离
|
||||||
|
float maxDis = distance(pointInBigEllipse, pointInEllipse);
|
||||||
|
|
||||||
|
// 5. 计算当前点到当前椭圆的距离
|
||||||
|
float curDis = distance(vec2(rx, ry), pointInEllipse);
|
||||||
|
|
||||||
|
// 6. 生成插值
|
||||||
|
float smo = smoothstep(0.0, maxDis, curDis);
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// mx * my = 0 时,代表非椭圆角区域,alpha 值为1,代表完全采用原始纹理的透明度
|
||||||
|
// mx * my = 1 时,代表椭圆角所在矩形区域
|
||||||
|
// isOutOfEllipse:
|
||||||
|
// 当点在椭圆外部时,此值为1,导致 alpha 最终值为0.0,即表示不显示椭圆外部的像素
|
||||||
|
// 当点在椭圆内部时,此值为0,导致 alpha 最终值为1.0,即表示显示椭圆内部的像素
|
||||||
|
// smo : 抗锯齿实现
|
||||||
|
// float alpha = 1.0 - mx * my * isOutOfEllipse;
|
||||||
|
float alpha = 1.0 - mx * my * isOutOfEllipse * smo;
|
||||||
|
|
||||||
|
o = vec4(o.rgb, o.a * alpha);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
gl_FragColor = o;
|
||||||
|
}
|
||||||
|
}%
|
17
assets/effects/sprite-round-corner-crop-v2.effect.meta
Normal file
17
assets/effects/sprite-round-corner-crop-v2.effect.meta
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.23",
|
||||||
|
"uuid": "7c24b57e-e819-4fc9-a8d2-b06cf61b782d",
|
||||||
|
"compiledShaders": [
|
||||||
|
{
|
||||||
|
"glsl1": {
|
||||||
|
"vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\n\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n",
|
||||||
|
"frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform float alphaThreshold;\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nvarying vec4 v_color;\n\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\n#if ENABLE_ROUNDCORNER\nuniform float xRadius;\nuniform float yRadius;\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n #if ENABLE_ROUNDCORNER\n\n float ellipseXRadius = clamp(0.0, 0.5, xRadius);\n float ellipseYRadius = clamp(0.0, 0.5, yRadius);\n\n vec2 uv = v_uv0.xy - vec2(0.5, 0.5);\n\n float rx = abs(uv.x) - (0.5 - ellipseXRadius);\n float ry = abs(uv.y) - (0.5 - ellipseYRadius);\n\n float mx = step(0.5 - ellipseXRadius, abs(uv.x));\n float my = step(0.5 - ellipseYRadius, abs(uv.y));\n\n float isOutOfEllipse = step(1.0, pow(rx, 2.0) / pow(xRadius, 2.0) + pow(ry, 2.0) / pow(yRadius, 2.0));\n\n float angleInRadian = atan(ry / rx);\n\n vec2 pointInEllipse = vec2(xRadius * cos(angleInRadian), yRadius * sin(angleInRadian));\n\n vec2 pointInBigEllipse = vec2((xRadius * 1.01) * cos(angleInRadian), (yRadius * 1.01)* sin(angleInRadian));\n\n float maxDis = distance(pointInBigEllipse, pointInEllipse);\n\n float curDis = distance(vec2(rx, ry), pointInEllipse);\n\n float smo = smoothstep(0.0, maxDis, curDis);\n\n float alpha = 1.0 - mx * my * isOutOfEllipse * smo;\n\n o = vec4(o.rgb, o.a * alpha);\n\n #endif\n gl_FragColor = o;\n}\n"
|
||||||
|
},
|
||||||
|
"glsl3": {
|
||||||
|
"vert": "\nprecision highp float;\nuniform CCGlobal {\n vec4 cc_time;\n\n vec4 cc_screenSize;\n\n vec4 cc_screenScale;\n\n vec4 cc_nativeSize;\n\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n\n vec4 cc_exposure;\n\n vec4 cc_mainLitDir;\n\n vec4 cc_mainLitColor;\n\n vec4 cc_ambientSky;\n vec4 cc_ambientGround;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\n\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\n\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n\n v_color = a_color;\n\n gl_Position = pos;\n}\n",
|
||||||
|
"frag": "\nprecision highp float;\n\n#if USE_ALPHA_TEST\n \n uniform ALPHA_TEST {\n float alphaThreshold;\n }\n#endif\n\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\n\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\n\nin vec4 v_color;\n\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n\n#if ENABLE_ROUNDCORNER\nuniform RoundCorner {\n\n float xRadius;\n\n float yRadius;\n}\n#endif\n\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n\n #if USE_TEXTURE\n o *= texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_TEXTURE\n o.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #endif\n\n o *= v_color;\n\n ALPHA_TEST(o);\n\n #if ENABLE_ROUNDCORNER\n\n float ellipseXRadius = clamp(0.0, 0.5, xRadius);\n float ellipseYRadius = clamp(0.0, 0.5, yRadius);\n\n vec2 uv = v_uv0.xy - vec2(0.5, 0.5);\n\n float rx = abs(uv.x) - (0.5 - ellipseXRadius);\n float ry = abs(uv.y) - (0.5 - ellipseYRadius);\n\n float mx = step(0.5 - ellipseXRadius, abs(uv.x));\n float my = step(0.5 - ellipseYRadius, abs(uv.y));\n\n float isOutOfEllipse = step(1.0, pow(rx, 2.0) / pow(xRadius, 2.0) + pow(ry, 2.0) / pow(yRadius, 2.0));\n\n float angleInRadian = atan(ry / rx);\n\n vec2 pointInEllipse = vec2(xRadius * cos(angleInRadian), yRadius * sin(angleInRadian));\n\n vec2 pointInBigEllipse = vec2((xRadius * 1.01) * cos(angleInRadian), (yRadius * 1.01)* sin(angleInRadian));\n\n float maxDis = distance(pointInBigEllipse, pointInEllipse);\n\n float curDis = distance(vec2(rx, ry), pointInEllipse);\n\n float smo = smoothstep(0.0, maxDis, curDis);\n\n float alpha = 1.0 - mx * my * isOutOfEllipse * smo;\n\n o = vec4(o.rgb, o.a * alpha);\n\n #endif\n gl_FragColor = o;\n}\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
24
assets/materials/sprite-flash-light.mtl
Normal file
24
assets/materials/sprite-flash-light.mtl
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"__type__": "cc.Material",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"_native": "",
|
||||||
|
"_effectAsset": {
|
||||||
|
"__uuid__": "e9682cd1-a19c-4fcb-ad8c-cf1783b805e6"
|
||||||
|
},
|
||||||
|
"_defines": {
|
||||||
|
"USE_TEXTURE": true,
|
||||||
|
"ENABLE_LIGHT": true
|
||||||
|
},
|
||||||
|
"_props": {
|
||||||
|
"lightColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 255,
|
||||||
|
"g": 245,
|
||||||
|
"b": 0,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"lightAngle": 36,
|
||||||
|
"lightWidth": 0.2
|
||||||
|
}
|
||||||
|
}
|
6
assets/materials/sprite-flash-light.mtl.meta
Normal file
6
assets/materials/sprite-flash-light.mtl.meta
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.2",
|
||||||
|
"uuid": "43a22f18-72fc-4399-b5ae-8305705861f4",
|
||||||
|
"dataAsSubAsset": null,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
@@ -10,7 +10,5 @@
|
|||||||
"USE_TEXTURE": true,
|
"USE_TEXTURE": true,
|
||||||
"ENABLE_ROUNDCORNER": true
|
"ENABLE_ROUNDCORNER": true
|
||||||
},
|
},
|
||||||
"_props": {
|
"_props": {}
|
||||||
"roundCornerRadius": 0.1
|
|
||||||
}
|
|
||||||
}
|
}
|
14
assets/materials/sprite-round-corner-crop-v2.mtl
Normal file
14
assets/materials/sprite-round-corner-crop-v2.mtl
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"__type__": "cc.Material",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"_native": "",
|
||||||
|
"_effectAsset": {
|
||||||
|
"__uuid__": "7c24b57e-e819-4fc9-a8d2-b06cf61b782d"
|
||||||
|
},
|
||||||
|
"_defines": {
|
||||||
|
"USE_TEXTURE": true,
|
||||||
|
"ENABLE_ROUNDCORNER": true
|
||||||
|
},
|
||||||
|
"_props": {}
|
||||||
|
}
|
6
assets/materials/sprite-round-corner-crop-v2.mtl.meta
Normal file
6
assets/materials/sprite-round-corner-crop-v2.mtl.meta
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.2",
|
||||||
|
"uuid": "a86e8864-5390-443f-b41b-b38e9d584c43",
|
||||||
|
"dataAsSubAsset": null,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
7640
assets/scenes/FlashLightEffectScene.fire
Executable file
7640
assets/scenes/FlashLightEffectScene.fire
Executable file
File diff suppressed because it is too large
Load Diff
7
assets/scenes/FlashLightEffectScene.fire.meta
Normal file
7
assets/scenes/FlashLightEffectScene.fire.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.5",
|
||||||
|
"uuid": "54bdad42-93aa-4869-a465-c0eac37bf0d2",
|
||||||
|
"asyncLoadAssets": false,
|
||||||
|
"autoReleaseAssets": false,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
@@ -78,10 +78,10 @@
|
|||||||
"_active": true,
|
"_active": true,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 47
|
"__id__": 39
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__id__": 48
|
"__id__": 40
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_prefab": null,
|
"_prefab": null,
|
||||||
@@ -171,7 +171,7 @@
|
|||||||
"array": [
|
"array": [
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
418.2902700278839,
|
351.60631393648214,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@@ -251,7 +251,7 @@
|
|||||||
"_active": true,
|
"_active": true,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 46
|
"__id__": 38
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_prefab": null,
|
"_prefab": null,
|
||||||
@@ -428,7 +428,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.Node",
|
"__type__": "cc.Node",
|
||||||
"_name": "Sliders",
|
"_name": "Controller",
|
||||||
"_objFlags": 0,
|
"_objFlags": 0,
|
||||||
"_parent": {
|
"_parent": {
|
||||||
"__id__": 5
|
"__id__": 5
|
||||||
@@ -497,7 +497,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.Node",
|
"__type__": "cc.Node",
|
||||||
"_name": "RoundCornerRadiusSlider",
|
"_name": "RadiusSlider",
|
||||||
"_objFlags": 0,
|
"_objFlags": 0,
|
||||||
"_parent": {
|
"_parent": {
|
||||||
"__id__": 9
|
"__id__": 9
|
||||||
@@ -1332,27 +1332,15 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__id__": 34
|
"__id__": 34
|
||||||
},
|
|
||||||
{
|
|
||||||
"__id__": 36
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"__id__": 38
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"__id__": 40
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"__id__": 42
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_active": true,
|
"_active": true,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 44
|
"__id__": 36
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__id__": 45
|
"__id__": 37
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_prefab": null,
|
"_prefab": null,
|
||||||
@@ -1367,7 +1355,7 @@
|
|||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 384,
|
"width": 384,
|
||||||
"height": 629.73
|
"height": 564
|
||||||
},
|
},
|
||||||
"_anchorPoint": {
|
"_anchorPoint": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
@@ -1403,100 +1391,6 @@
|
|||||||
"groupIndex": 0,
|
"groupIndex": 0,
|
||||||
"_id": "feymBChPxA1pr6+/rlPqey"
|
"_id": "feymBChPxA1pr6+/rlPqey"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"__type__": "cc.Node",
|
|
||||||
"_name": "ball_0",
|
|
||||||
"_objFlags": 0,
|
|
||||||
"_parent": {
|
|
||||||
"__id__": 29
|
|
||||||
},
|
|
||||||
"_children": [],
|
|
||||||
"_active": false,
|
|
||||||
"_components": [
|
|
||||||
{
|
|
||||||
"__id__": 31
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"_prefab": null,
|
|
||||||
"_opacity": 255,
|
|
||||||
"_color": {
|
|
||||||
"__type__": "cc.Color",
|
|
||||||
"r": 255,
|
|
||||||
"g": 255,
|
|
||||||
"b": 255,
|
|
||||||
"a": 255
|
|
||||||
},
|
|
||||||
"_contentSize": {
|
|
||||||
"__type__": "cc.Size",
|
|
||||||
"width": 60,
|
|
||||||
"height": 60
|
|
||||||
},
|
|
||||||
"_anchorPoint": {
|
|
||||||
"__type__": "cc.Vec2",
|
|
||||||
"x": 0.5,
|
|
||||||
"y": 0.5
|
|
||||||
},
|
|
||||||
"_trs": {
|
|
||||||
"__type__": "TypedArray",
|
|
||||||
"ctor": "Float64Array",
|
|
||||||
"array": [
|
|
||||||
0,
|
|
||||||
-30,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"_eulerAngles": {
|
|
||||||
"__type__": "cc.Vec3",
|
|
||||||
"x": 0,
|
|
||||||
"y": 0,
|
|
||||||
"z": 0
|
|
||||||
},
|
|
||||||
"_skewX": 0,
|
|
||||||
"_skewY": 0,
|
|
||||||
"_is3DNode": false,
|
|
||||||
"_groupIndex": 0,
|
|
||||||
"groupIndex": 0,
|
|
||||||
"_id": "49czqIEPBHr6kLJbb+kN8/"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"__type__": "cc.Sprite",
|
|
||||||
"_name": "",
|
|
||||||
"_objFlags": 0,
|
|
||||||
"node": {
|
|
||||||
"__id__": 30
|
|
||||||
},
|
|
||||||
"_enabled": true,
|
|
||||||
"_materials": [
|
|
||||||
{
|
|
||||||
"__uuid__": "642c2d0e-7eb6-4d65-96f2-d6e0d0305310"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"_srcBlendFactor": 770,
|
|
||||||
"_dstBlendFactor": 771,
|
|
||||||
"_spriteFrame": {
|
|
||||||
"__uuid__": "d0b78623-4e79-4de1-b1d2-ea211bf4652c"
|
|
||||||
},
|
|
||||||
"_type": 0,
|
|
||||||
"_sizeMode": 1,
|
|
||||||
"_fillType": 0,
|
|
||||||
"_fillCenter": {
|
|
||||||
"__type__": "cc.Vec2",
|
|
||||||
"x": 0,
|
|
||||||
"y": 0
|
|
||||||
},
|
|
||||||
"_fillStart": 0,
|
|
||||||
"_fillRange": 0,
|
|
||||||
"_isTrimmedMode": true,
|
|
||||||
"_atlas": null,
|
|
||||||
"_id": "94vIBMHVlAN4EGbkr2wRvX"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"__type__": "cc.Node",
|
"__type__": "cc.Node",
|
||||||
"_name": "freedom",
|
"_name": "freedom",
|
||||||
@@ -1508,7 +1402,7 @@
|
|||||||
"_active": true,
|
"_active": true,
|
||||||
"_components": [
|
"_components": [
|
||||||
{
|
{
|
||||||
"__id__": 33
|
"__id__": 31
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"_prefab": null,
|
"_prefab": null,
|
||||||
@@ -1564,7 +1458,7 @@
|
|||||||
"_name": "",
|
"_name": "",
|
||||||
"_objFlags": 0,
|
"_objFlags": 0,
|
||||||
"node": {
|
"node": {
|
||||||
"__id__": 32
|
"__id__": 30
|
||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"_materials": [
|
"_materials": [
|
||||||
@@ -1593,7 +1487,101 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.Node",
|
"__type__": "cc.Node",
|
||||||
"_name": "cocos_logo",
|
"_name": "Rectangle1",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"_parent": {
|
||||||
|
"__id__": 29
|
||||||
|
},
|
||||||
|
"_children": [],
|
||||||
|
"_active": true,
|
||||||
|
"_components": [
|
||||||
|
{
|
||||||
|
"__id__": 33
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_prefab": null,
|
||||||
|
"_opacity": 255,
|
||||||
|
"_color": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 255,
|
||||||
|
"g": 0,
|
||||||
|
"b": 0,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_contentSize": {
|
||||||
|
"__type__": "cc.Size",
|
||||||
|
"width": 200,
|
||||||
|
"height": 100
|
||||||
|
},
|
||||||
|
"_anchorPoint": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0.5,
|
||||||
|
"y": 0.5
|
||||||
|
},
|
||||||
|
"_trs": {
|
||||||
|
"__type__": "TypedArray",
|
||||||
|
"ctor": "Float64Array",
|
||||||
|
"array": [
|
||||||
|
0,
|
||||||
|
-302,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"_eulerAngles": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"_skewX": 0,
|
||||||
|
"_skewY": 0,
|
||||||
|
"_is3DNode": false,
|
||||||
|
"_groupIndex": 0,
|
||||||
|
"groupIndex": 0,
|
||||||
|
"_id": "2eSZfgubZMxpkxf6Wv6VoZ"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Sprite",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"node": {
|
||||||
|
"__id__": 32
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"_materials": [
|
||||||
|
{
|
||||||
|
"__uuid__": "642c2d0e-7eb6-4d65-96f2-d6e0d0305310"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_srcBlendFactor": 770,
|
||||||
|
"_dstBlendFactor": 771,
|
||||||
|
"_spriteFrame": {
|
||||||
|
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
|
||||||
|
},
|
||||||
|
"_type": 0,
|
||||||
|
"_sizeMode": 0,
|
||||||
|
"_fillType": 0,
|
||||||
|
"_fillCenter": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"_fillStart": 0,
|
||||||
|
"_fillRange": 0,
|
||||||
|
"_isTrimmedMode": true,
|
||||||
|
"_atlas": null,
|
||||||
|
"_id": "2enlbFjsJLJqVy8iYfWwca"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Node",
|
||||||
|
"_name": "Rectangle2",
|
||||||
"_objFlags": 0,
|
"_objFlags": 0,
|
||||||
"_parent": {
|
"_parent": {
|
||||||
"__id__": 29
|
"__id__": 29
|
||||||
@@ -1611,13 +1599,13 @@
|
|||||||
"__type__": "cc.Color",
|
"__type__": "cc.Color",
|
||||||
"r": 255,
|
"r": 255,
|
||||||
"g": 255,
|
"g": 255,
|
||||||
"b": 255,
|
"b": 0,
|
||||||
"a": 255
|
"a": 255
|
||||||
},
|
},
|
||||||
"_contentSize": {
|
"_contentSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 195,
|
"width": 100,
|
||||||
"height": 270
|
"height": 200
|
||||||
},
|
},
|
||||||
"_anchorPoint": {
|
"_anchorPoint": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
@@ -1629,7 +1617,7 @@
|
|||||||
"ctor": "Float64Array",
|
"ctor": "Float64Array",
|
||||||
"array": [
|
"array": [
|
||||||
0,
|
0,
|
||||||
-387,
|
-464,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@@ -1651,7 +1639,7 @@
|
|||||||
"_is3DNode": false,
|
"_is3DNode": false,
|
||||||
"_groupIndex": 0,
|
"_groupIndex": 0,
|
||||||
"groupIndex": 0,
|
"groupIndex": 0,
|
||||||
"_id": "25JHa6EcNEBZ1hoesQM1Q4"
|
"_id": "eeRQw29nZJXYOderYE6uKz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.Sprite",
|
"__type__": "cc.Sprite",
|
||||||
@@ -1669,10 +1657,10 @@
|
|||||||
"_srcBlendFactor": 770,
|
"_srcBlendFactor": 770,
|
||||||
"_dstBlendFactor": 771,
|
"_dstBlendFactor": 771,
|
||||||
"_spriteFrame": {
|
"_spriteFrame": {
|
||||||
"__uuid__": "31bc895a-c003-4566-a9f3-2e54ae1c17dc"
|
"__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91"
|
||||||
},
|
},
|
||||||
"_type": 0,
|
"_type": 0,
|
||||||
"_sizeMode": 1,
|
"_sizeMode": 0,
|
||||||
"_fillType": 0,
|
"_fillType": 0,
|
||||||
"_fillCenter": {
|
"_fillCenter": {
|
||||||
"__type__": "cc.Vec2",
|
"__type__": "cc.Vec2",
|
||||||
@@ -1683,381 +1671,7 @@
|
|||||||
"_fillRange": 0,
|
"_fillRange": 0,
|
||||||
"_isTrimmedMode": true,
|
"_isTrimmedMode": true,
|
||||||
"_atlas": null,
|
"_atlas": null,
|
||||||
"_id": "74+WCqN01NIbcSpr5gcxmE"
|
"_id": "0c/FhoiupJMaG6rjicnytU"
|
||||||
},
|
|
||||||
{
|
|
||||||
"__type__": "cc.Node",
|
|
||||||
"_name": "ball_1",
|
|
||||||
"_objFlags": 0,
|
|
||||||
"_parent": {
|
|
||||||
"__id__": 29
|
|
||||||
},
|
|
||||||
"_children": [],
|
|
||||||
"_active": false,
|
|
||||||
"_components": [
|
|
||||||
{
|
|
||||||
"__id__": 37
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"_prefab": null,
|
|
||||||
"_opacity": 255,
|
|
||||||
"_color": {
|
|
||||||
"__type__": "cc.Color",
|
|
||||||
"r": 255,
|
|
||||||
"g": 255,
|
|
||||||
"b": 255,
|
|
||||||
"a": 255
|
|
||||||
},
|
|
||||||
"_contentSize": {
|
|
||||||
"__type__": "cc.Size",
|
|
||||||
"width": 60,
|
|
||||||
"height": 60
|
|
||||||
},
|
|
||||||
"_anchorPoint": {
|
|
||||||
"__type__": "cc.Vec2",
|
|
||||||
"x": 0.5,
|
|
||||||
"y": 0.5
|
|
||||||
},
|
|
||||||
"_trs": {
|
|
||||||
"__type__": "TypedArray",
|
|
||||||
"ctor": "Float64Array",
|
|
||||||
"array": [
|
|
||||||
0,
|
|
||||||
-564,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"_eulerAngles": {
|
|
||||||
"__type__": "cc.Vec3",
|
|
||||||
"x": 0,
|
|
||||||
"y": 0,
|
|
||||||
"z": 0
|
|
||||||
},
|
|
||||||
"_skewX": 0,
|
|
||||||
"_skewY": 0,
|
|
||||||
"_is3DNode": false,
|
|
||||||
"_groupIndex": 0,
|
|
||||||
"groupIndex": 0,
|
|
||||||
"_id": "08wsP0gQdCnrq+UzPWkn0+"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"__type__": "cc.Sprite",
|
|
||||||
"_name": "",
|
|
||||||
"_objFlags": 0,
|
|
||||||
"node": {
|
|
||||||
"__id__": 36
|
|
||||||
},
|
|
||||||
"_enabled": true,
|
|
||||||
"_materials": [
|
|
||||||
{
|
|
||||||
"__uuid__": "642c2d0e-7eb6-4d65-96f2-d6e0d0305310"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"_srcBlendFactor": 770,
|
|
||||||
"_dstBlendFactor": 771,
|
|
||||||
"_spriteFrame": {
|
|
||||||
"__uuid__": "969fa66a-ae10-4157-b16e-4c1a4665920c"
|
|
||||||
},
|
|
||||||
"_type": 0,
|
|
||||||
"_sizeMode": 1,
|
|
||||||
"_fillType": 0,
|
|
||||||
"_fillCenter": {
|
|
||||||
"__type__": "cc.Vec2",
|
|
||||||
"x": 0,
|
|
||||||
"y": 0
|
|
||||||
},
|
|
||||||
"_fillStart": 0,
|
|
||||||
"_fillRange": 0,
|
|
||||||
"_isTrimmedMode": true,
|
|
||||||
"_atlas": null,
|
|
||||||
"_id": "4bH5hzKe9LsLQeXjLynIHQ"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"__type__": "cc.Node",
|
|
||||||
"_name": "video_btn",
|
|
||||||
"_objFlags": 0,
|
|
||||||
"_parent": {
|
|
||||||
"__id__": 29
|
|
||||||
},
|
|
||||||
"_children": [],
|
|
||||||
"_active": false,
|
|
||||||
"_components": [
|
|
||||||
{
|
|
||||||
"__id__": 39
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"_prefab": null,
|
|
||||||
"_opacity": 255,
|
|
||||||
"_color": {
|
|
||||||
"__type__": "cc.Color",
|
|
||||||
"r": 255,
|
|
||||||
"g": 255,
|
|
||||||
"b": 255,
|
|
||||||
"a": 255
|
|
||||||
},
|
|
||||||
"_contentSize": {
|
|
||||||
"__type__": "cc.Size",
|
|
||||||
"width": 50,
|
|
||||||
"height": 50
|
|
||||||
},
|
|
||||||
"_anchorPoint": {
|
|
||||||
"__type__": "cc.Vec2",
|
|
||||||
"x": 0.5,
|
|
||||||
"y": 0.5
|
|
||||||
},
|
|
||||||
"_trs": {
|
|
||||||
"__type__": "TypedArray",
|
|
||||||
"ctor": "Float64Array",
|
|
||||||
"array": [
|
|
||||||
0,
|
|
||||||
-631,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"_eulerAngles": {
|
|
||||||
"__type__": "cc.Vec3",
|
|
||||||
"x": 0,
|
|
||||||
"y": 0,
|
|
||||||
"z": 0
|
|
||||||
},
|
|
||||||
"_skewX": 0,
|
|
||||||
"_skewY": 0,
|
|
||||||
"_is3DNode": false,
|
|
||||||
"_groupIndex": 0,
|
|
||||||
"groupIndex": 0,
|
|
||||||
"_id": "c73V7fMuVE0aD5fGtmyzmF"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"__type__": "cc.Sprite",
|
|
||||||
"_name": "",
|
|
||||||
"_objFlags": 0,
|
|
||||||
"node": {
|
|
||||||
"__id__": 38
|
|
||||||
},
|
|
||||||
"_enabled": true,
|
|
||||||
"_materials": [
|
|
||||||
{
|
|
||||||
"__uuid__": "642c2d0e-7eb6-4d65-96f2-d6e0d0305310"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"_srcBlendFactor": 770,
|
|
||||||
"_dstBlendFactor": 771,
|
|
||||||
"_spriteFrame": {
|
|
||||||
"__uuid__": "54142b08-a163-426e-a75e-4c7b21046413"
|
|
||||||
},
|
|
||||||
"_type": 0,
|
|
||||||
"_sizeMode": 1,
|
|
||||||
"_fillType": 0,
|
|
||||||
"_fillCenter": {
|
|
||||||
"__type__": "cc.Vec2",
|
|
||||||
"x": 0,
|
|
||||||
"y": 0
|
|
||||||
},
|
|
||||||
"_fillStart": 0,
|
|
||||||
"_fillRange": 0,
|
|
||||||
"_isTrimmedMode": true,
|
|
||||||
"_atlas": null,
|
|
||||||
"_id": "f43fJCjNdOS5VHAEhp0yDU"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"__type__": "cc.Node",
|
|
||||||
"_name": "SystemFont",
|
|
||||||
"_objFlags": 0,
|
|
||||||
"_parent": {
|
|
||||||
"__id__": 29
|
|
||||||
},
|
|
||||||
"_children": [],
|
|
||||||
"_active": true,
|
|
||||||
"_components": [
|
|
||||||
{
|
|
||||||
"__id__": 41
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"_prefab": null,
|
|
||||||
"_opacity": 255,
|
|
||||||
"_color": {
|
|
||||||
"__type__": "cc.Color",
|
|
||||||
"r": 255,
|
|
||||||
"g": 255,
|
|
||||||
"b": 255,
|
|
||||||
"a": 255
|
|
||||||
},
|
|
||||||
"_contentSize": {
|
|
||||||
"__type__": "cc.Size",
|
|
||||||
"width": 224.51,
|
|
||||||
"height": 50.4
|
|
||||||
},
|
|
||||||
"_anchorPoint": {
|
|
||||||
"__type__": "cc.Vec2",
|
|
||||||
"x": 0.5,
|
|
||||||
"y": 0.5
|
|
||||||
},
|
|
||||||
"_trs": {
|
|
||||||
"__type__": "TypedArray",
|
|
||||||
"ctor": "Float64Array",
|
|
||||||
"array": [
|
|
||||||
0,
|
|
||||||
-559.2,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"_eulerAngles": {
|
|
||||||
"__type__": "cc.Vec3",
|
|
||||||
"x": 0,
|
|
||||||
"y": 0,
|
|
||||||
"z": 0
|
|
||||||
},
|
|
||||||
"_skewX": 0,
|
|
||||||
"_skewY": 0,
|
|
||||||
"_is3DNode": false,
|
|
||||||
"_groupIndex": 0,
|
|
||||||
"groupIndex": 0,
|
|
||||||
"_id": "5dfIaYLgJPQKk50HqrgyHI"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"__type__": "cc.Label",
|
|
||||||
"_name": "",
|
|
||||||
"_objFlags": 0,
|
|
||||||
"node": {
|
|
||||||
"__id__": 40
|
|
||||||
},
|
|
||||||
"_enabled": true,
|
|
||||||
"_materials": [
|
|
||||||
{
|
|
||||||
"__uuid__": "642c2d0e-7eb6-4d65-96f2-d6e0d0305310"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"_useOriginalSize": false,
|
|
||||||
"_string": "System Font",
|
|
||||||
"_N$string": "System Font",
|
|
||||||
"_fontSize": 40,
|
|
||||||
"_lineHeight": 40,
|
|
||||||
"_enableWrapText": true,
|
|
||||||
"_N$file": null,
|
|
||||||
"_isSystemFontUsed": true,
|
|
||||||
"_spacingX": 0,
|
|
||||||
"_batchAsBitmap": false,
|
|
||||||
"_N$horizontalAlign": 1,
|
|
||||||
"_N$verticalAlign": 1,
|
|
||||||
"_N$fontFamily": "Arial",
|
|
||||||
"_N$overflow": 0,
|
|
||||||
"_N$cacheMode": 0,
|
|
||||||
"_id": "d1whc7H8RHdrROcYj+2Qh1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"__type__": "cc.Node",
|
|
||||||
"_name": "BmFont",
|
|
||||||
"_objFlags": 0,
|
|
||||||
"_parent": {
|
|
||||||
"__id__": 29
|
|
||||||
},
|
|
||||||
"_children": [],
|
|
||||||
"_active": true,
|
|
||||||
"_components": [
|
|
||||||
{
|
|
||||||
"__id__": 43
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"_prefab": null,
|
|
||||||
"_opacity": 255,
|
|
||||||
"_color": {
|
|
||||||
"__type__": "cc.Color",
|
|
||||||
"r": 255,
|
|
||||||
"g": 255,
|
|
||||||
"b": 255,
|
|
||||||
"a": 255
|
|
||||||
},
|
|
||||||
"_contentSize": {
|
|
||||||
"__type__": "cc.Size",
|
|
||||||
"width": 167.5,
|
|
||||||
"height": 33.33
|
|
||||||
},
|
|
||||||
"_anchorPoint": {
|
|
||||||
"__type__": "cc.Vec2",
|
|
||||||
"x": 0.5,
|
|
||||||
"y": 0.5
|
|
||||||
},
|
|
||||||
"_trs": {
|
|
||||||
"__type__": "TypedArray",
|
|
||||||
"ctor": "Float64Array",
|
|
||||||
"array": [
|
|
||||||
0,
|
|
||||||
-613.065,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"_eulerAngles": {
|
|
||||||
"__type__": "cc.Vec3",
|
|
||||||
"x": 0,
|
|
||||||
"y": 0,
|
|
||||||
"z": 0
|
|
||||||
},
|
|
||||||
"_skewX": 0,
|
|
||||||
"_skewY": 0,
|
|
||||||
"_is3DNode": false,
|
|
||||||
"_groupIndex": 0,
|
|
||||||
"groupIndex": 0,
|
|
||||||
"_id": "e4XmdmRoVPxKoDxfbOgm42"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"__type__": "cc.Label",
|
|
||||||
"_name": "",
|
|
||||||
"_objFlags": 0,
|
|
||||||
"node": {
|
|
||||||
"__id__": 42
|
|
||||||
},
|
|
||||||
"_enabled": true,
|
|
||||||
"_materials": [
|
|
||||||
{
|
|
||||||
"__uuid__": "642c2d0e-7eb6-4d65-96f2-d6e0d0305310"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"_useOriginalSize": false,
|
|
||||||
"_string": "BM Font",
|
|
||||||
"_N$string": "BM Font",
|
|
||||||
"_fontSize": 40,
|
|
||||||
"_lineHeight": 40,
|
|
||||||
"_enableWrapText": true,
|
|
||||||
"_N$file": {
|
|
||||||
"__uuid__": "4c95de7e-8cca-47bf-a446-47b7594e0992"
|
|
||||||
},
|
|
||||||
"_isSystemFontUsed": false,
|
|
||||||
"_spacingX": 0,
|
|
||||||
"_batchAsBitmap": false,
|
|
||||||
"_N$horizontalAlign": 1,
|
|
||||||
"_N$verticalAlign": 1,
|
|
||||||
"_N$fontFamily": "Arial",
|
|
||||||
"_N$overflow": 0,
|
|
||||||
"_N$cacheMode": 0,
|
|
||||||
"_id": "7cXLgoUJhDP7BPjr4yx+Ep"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "cc.Widget",
|
"__type__": "cc.Widget",
|
||||||
@@ -2097,7 +1711,7 @@
|
|||||||
"_layoutSize": {
|
"_layoutSize": {
|
||||||
"__type__": "cc.Size",
|
"__type__": "cc.Size",
|
||||||
"width": 384,
|
"width": 384,
|
||||||
"height": 629.73
|
"height": 564
|
||||||
},
|
},
|
||||||
"_resize": 1,
|
"_resize": 1,
|
||||||
"_N$layoutType": 2,
|
"_N$layoutType": 2,
|
||||||
@@ -2147,13 +1761,13 @@
|
|||||||
"_id": "4bz2+ak99DBYVlSVIMFGN0"
|
"_id": "4bz2+ak99DBYVlSVIMFGN0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"__type__": "d3d2b7nIXNDbKEclKMbIFTC",
|
"__type__": "d2765jFqWZOUKFiCcevAVee",
|
||||||
"_name": "",
|
"_name": "",
|
||||||
"_objFlags": 0,
|
"_objFlags": 0,
|
||||||
"node": {
|
"node": {
|
||||||
"__id__": 2
|
"__id__": 2
|
||||||
},
|
},
|
||||||
"_enabled": true,
|
"_enabled": true,
|
||||||
"_id": "9ayfD37bZP1IEjPxGKO6+/"
|
"_id": "ffrfD4b9VHdpBJCBGtbsue"
|
||||||
}
|
}
|
||||||
]
|
]
|
1773
assets/scenes/RoundCornerCropV2EffectScene.fire
Executable file
1773
assets/scenes/RoundCornerCropV2EffectScene.fire
Executable file
File diff suppressed because it is too large
Load Diff
7
assets/scenes/RoundCornerCropV2EffectScene.fire.meta
Normal file
7
assets/scenes/RoundCornerCropV2EffectScene.fire.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.5",
|
||||||
|
"uuid": "c2dec4ed-8129-40a2-9a1e-2440da772015",
|
||||||
|
"asyncLoadAssets": false,
|
||||||
|
"autoReleaseAssets": false,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
97
assets/scripts/FlashLightCtrlComponent.ts
Normal file
97
assets/scripts/FlashLightCtrlComponent.ts
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
const { ccclass, property } = cc._decorator;
|
||||||
|
|
||||||
|
@ccclass
|
||||||
|
export default class FlashLightCtrlComponent extends cc.Component {
|
||||||
|
private _flashLightUBO: FlashLightUBO = new FlashLightUBO();
|
||||||
|
|
||||||
|
onEnable() {
|
||||||
|
this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchStart, this);
|
||||||
|
this.node.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this);
|
||||||
|
this.node.on("on_property_change", this._onPropertyChange, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
onDisable() {
|
||||||
|
this.node.off(cc.Node.EventType.TOUCH_START, this._onTouchStart, this);
|
||||||
|
this.node.off(cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this);
|
||||||
|
this.node.off("on_property_change", this._onPropertyChange, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _onTouchStart(event: cc.Event.EventTouch) {
|
||||||
|
this._onTouchMove(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _onTouchMove(event: cc.Event.EventTouch) {
|
||||||
|
let touchPointInWorldSpace = event.getLocation();
|
||||||
|
let touchPointInNodeSpace = this.node.convertToNodeSpaceAR(touchPointInWorldSpace);
|
||||||
|
|
||||||
|
// 将触摸点转换为OPENGL坐标系并归一化
|
||||||
|
// OpenGl 坐标系原点在左上角
|
||||||
|
this._flashLightUBO.lightCenterPoint = cc.v2(
|
||||||
|
this.node.anchorX + touchPointInNodeSpace.x / this.node.width,
|
||||||
|
1 - (this.node.anchorY + touchPointInNodeSpace.y / this.node.height)
|
||||||
|
);
|
||||||
|
|
||||||
|
this._updateMaterial();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _onPropertyChange(localDiffusionUniform: FlashLightUBO) {
|
||||||
|
this._flashLightUBO.lightColor = localDiffusionUniform.lightColor;
|
||||||
|
this._flashLightUBO.lightAngle = localDiffusionUniform.lightAngle;
|
||||||
|
this._flashLightUBO.lightWidth = localDiffusionUniform.lightWidth;
|
||||||
|
this._flashLightUBO.enableGradient = localDiffusionUniform.enableGradient;
|
||||||
|
this._flashLightUBO.cropAlpha = localDiffusionUniform.cropAlpha;
|
||||||
|
this._flashLightUBO.enableFog = localDiffusionUniform.enableFog;
|
||||||
|
this._updateMaterial();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _updateMaterial() {
|
||||||
|
this.getComponents(cc.RenderComponent).forEach(renderComponent => {
|
||||||
|
let material: cc.Material = renderComponent.getMaterial(0);
|
||||||
|
material.setProperty("lightColor", this._flashLightUBO.lightColor);
|
||||||
|
material.setProperty("lightCenterPoint", this._flashLightUBO.lightCenterPoint);
|
||||||
|
material.setProperty("lightAngle", this._flashLightUBO.lightAngle);
|
||||||
|
material.setProperty("lightWidth", this._flashLightUBO.lightWidth);
|
||||||
|
material.setProperty("enableGradient", this._flashLightUBO.enableGradient);
|
||||||
|
material.setProperty("cropAlpha", this._flashLightUBO.cropAlpha);
|
||||||
|
material.setProperty("enableFog", this._flashLightUBO.enableFog);
|
||||||
|
renderComponent.setMaterial(0, material);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class FlashLightUBO {
|
||||||
|
/**
|
||||||
|
* 中心点颜色
|
||||||
|
*/
|
||||||
|
lightColor: cc.Color = cc.Color.YELLOW;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中心点坐标 ([0.0, 1.0], [0.0, 1.0])
|
||||||
|
*/
|
||||||
|
lightCenterPoint: cc.Vec2 = cc.v2(0.5, 0.5);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 光束角度 [0.0, 180.0]
|
||||||
|
*/
|
||||||
|
lightAngle: number = 45;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 光束宽度 [0.0, +∞]
|
||||||
|
*/
|
||||||
|
lightWidth: number = 0.5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用光束渐变
|
||||||
|
*/
|
||||||
|
enableGradient: boolean = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否裁剪掉透明区域上的点光
|
||||||
|
*/
|
||||||
|
cropAlpha: boolean = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否开启战争迷雾效果
|
||||||
|
*/
|
||||||
|
enableFog: boolean = false;
|
||||||
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ver": "1.0.5",
|
"ver": "1.0.5",
|
||||||
"uuid": "d3d2bee7-2173-436c-a11c-94a31b2054c2",
|
"uuid": "3edca38f-0f12-489f-847a-0d89d9e55c6c",
|
||||||
"isPlugin": false,
|
"isPlugin": false,
|
||||||
"loadPluginInWeb": true,
|
"loadPluginInWeb": true,
|
||||||
"loadPluginInNative": true,
|
"loadPluginInNative": true,
|
111
assets/scripts/FlashLightEffectScene.ts
Normal file
111
assets/scripts/FlashLightEffectScene.ts
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
import FlashLightCtrlComponent, { FlashLightUBO } from "./FlashLightCtrlComponent";
|
||||||
|
|
||||||
|
const { ccclass, property } = cc._decorator;
|
||||||
|
|
||||||
|
@ccclass
|
||||||
|
export default class FlashLightEffectScene extends cc.Component {
|
||||||
|
private _redSlider: cc.Slider = null;
|
||||||
|
private _redSliderLabel: cc.Label = null;
|
||||||
|
private _greenSlider: cc.Slider = null;
|
||||||
|
private _greenSliderLabel: cc.Label = null;
|
||||||
|
private _blueSlider: cc.Slider = null;
|
||||||
|
private _blueSliderLabel: cc.Label = null;
|
||||||
|
private _alphaSlider: cc.Slider = null;
|
||||||
|
private _alphaSliderLabel: cc.Label = null;
|
||||||
|
private _lightWidthSlider: cc.Slider = null;
|
||||||
|
private _lightWidthSliderLabel: cc.Label = null;
|
||||||
|
private _lightAngleSlider: cc.Slider = null;
|
||||||
|
private _lightAngleSliderLabel: cc.Label = null;
|
||||||
|
|
||||||
|
private _enableGradientToggle: cc.Toggle = null;
|
||||||
|
private _cropAlphaToggle: cc.Toggle = null;
|
||||||
|
private _enableFogToggle: cc.Toggle = null;
|
||||||
|
|
||||||
|
private _examplesParentNode: cc.Node = null;
|
||||||
|
|
||||||
|
onLoad() {
|
||||||
|
cc.dynamicAtlasManager.enabled = false;
|
||||||
|
|
||||||
|
this._redSlider = cc.find("Canvas/Content/Controller/ColorRedSlider/Slider").getComponent(cc.Slider);
|
||||||
|
this._redSliderLabel = cc.find("Canvas/Content/Controller/ColorRedSlider/ValueLabel").getComponent(cc.Label);
|
||||||
|
this._greenSlider = cc.find("Canvas/Content/Controller/ColorGreenSlider/Slider").getComponent(cc.Slider);
|
||||||
|
this._greenSliderLabel = cc.find("Canvas/Content/Controller/ColorGreenSlider/ValueLabel").getComponent(cc.Label);
|
||||||
|
this._blueSlider = cc.find("Canvas/Content/Controller/ColorBlueSlider/Slider").getComponent(cc.Slider);
|
||||||
|
this._blueSliderLabel = cc.find("Canvas/Content/Controller/ColorBlueSlider/ValueLabel").getComponent(cc.Label);
|
||||||
|
this._alphaSlider = cc.find("Canvas/Content/Controller/ColorAlphaSlider/Slider").getComponent(cc.Slider);
|
||||||
|
this._alphaSliderLabel = cc.find("Canvas/Content/Controller/ColorAlphaSlider/ValueLabel").getComponent(cc.Label);
|
||||||
|
this._lightWidthSlider = cc.find("Canvas/Content/Controller/LightWidthSlider/Slider").getComponent(cc.Slider);
|
||||||
|
this._lightWidthSliderLabel = cc.find("Canvas/Content/Controller/LightWidthSlider/ValueLabel").getComponent(cc.Label);
|
||||||
|
this._lightAngleSlider = cc.find("Canvas/Content/Controller/LightAngleSlider/Slider").getComponent(cc.Slider);
|
||||||
|
this._lightAngleSliderLabel = cc.find("Canvas/Content/Controller/LightAngleSlider/ValueLabel").getComponent(cc.Label);
|
||||||
|
|
||||||
|
this._enableGradientToggle = cc.find("Canvas/Content/Controller/EnableGradientToggle/Toggle").getComponent(cc.Toggle);
|
||||||
|
this._cropAlphaToggle = cc.find("Canvas/Content/Controller/CropAlphaToggle/Toggle").getComponent(cc.Toggle);
|
||||||
|
this._enableFogToggle = cc.find("Canvas/Content/Controller/EnableFogToggle/Toggle").getComponent(cc.Toggle);
|
||||||
|
|
||||||
|
// 代码添加控制脚本
|
||||||
|
this._examplesParentNode = cc.find("Canvas/Content/Examples");
|
||||||
|
this._examplesParentNode.children.forEach(childNode => {
|
||||||
|
childNode.addComponent(FlashLightCtrlComponent);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onEnable() {
|
||||||
|
this._redSlider.node.on("slide", this._onPropertyChanged, this);
|
||||||
|
this._greenSlider.node.on("slide", this._onPropertyChanged, this);
|
||||||
|
this._blueSlider.node.on("slide", this._onPropertyChanged, this);
|
||||||
|
this._alphaSlider.node.on("slide", this._onPropertyChanged, this);
|
||||||
|
this._lightWidthSlider.node.on("slide", this._onPropertyChanged, this);
|
||||||
|
this._lightAngleSlider.node.on("slide", this._onPropertyChanged, this);
|
||||||
|
|
||||||
|
this._enableGradientToggle.node.on("toggle", this._onPropertyChanged, this);
|
||||||
|
this._cropAlphaToggle.node.on("toggle", this._onPropertyChanged, this);
|
||||||
|
this._enableFogToggle.node.on("toggle", this._onPropertyChanged, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
onDisable() {
|
||||||
|
this._redSlider.node.off("slide", this._onPropertyChanged, this);
|
||||||
|
this._greenSlider.node.off("slide", this._onPropertyChanged, this);
|
||||||
|
this._blueSlider.node.off("slide", this._onPropertyChanged, this);
|
||||||
|
this._alphaSlider.node.off("slide", this._onPropertyChanged, this);
|
||||||
|
this._lightWidthSlider.node.off("slide", this._onPropertyChanged, this);
|
||||||
|
this._lightAngleSlider.node.off("slide", this._onPropertyChanged, this);
|
||||||
|
|
||||||
|
this._enableGradientToggle.node.off("toggle", this._onPropertyChanged, this);
|
||||||
|
this._cropAlphaToggle.node.off("toggle", this._onPropertyChanged, this);
|
||||||
|
this._enableFogToggle.node.off("toggle", this._onPropertyChanged, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
this._onPropertyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _onPropertyChanged() {
|
||||||
|
// 更新进度条值 Label 文本
|
||||||
|
this._redSliderLabel.string = `${this._redSlider.progress.toFixed(2)} | ${Math.round(255 * this._redSlider.progress)}`;
|
||||||
|
this._greenSliderLabel.string = `${this._greenSlider.progress.toFixed(2)} | ${Math.round(255 * this._greenSlider.progress)}`;
|
||||||
|
this._blueSliderLabel.string = `${this._blueSlider.progress.toFixed(2)} | ${Math.round(255 * this._blueSlider.progress)}`;
|
||||||
|
this._alphaSliderLabel.string = `${this._alphaSlider.progress.toFixed(2)} | ${Math.round(255 * this._alphaSlider.progress)}`;
|
||||||
|
this._lightWidthSliderLabel.string = `${this._lightWidthSlider.progress.toFixed(2)}`;
|
||||||
|
|
||||||
|
let angle = 180 * this._lightAngleSlider.progress;
|
||||||
|
this._lightAngleSliderLabel.string = `${this._lightAngleSlider.progress.toFixed(2)} | ${angle.toFixed(2)}`;
|
||||||
|
|
||||||
|
// 通知子节点更新材质
|
||||||
|
this._examplesParentNode.children.forEach(childNode => {
|
||||||
|
childNode.emit("on_property_change", <FlashLightUBO>{
|
||||||
|
lightColor: cc.color(
|
||||||
|
Math.round(255 * this._redSlider.progress),
|
||||||
|
Math.round(255 * this._greenSlider.progress),
|
||||||
|
Math.round(255 * this._blueSlider.progress),
|
||||||
|
Math.round(255 * this._alphaSlider.progress)
|
||||||
|
),
|
||||||
|
lightAngle: angle,
|
||||||
|
lightWidth: this._lightWidthSlider.progress,
|
||||||
|
enableGradient: this._enableGradientToggle.isChecked,
|
||||||
|
cropAlpha: this._cropAlphaToggle.isChecked,
|
||||||
|
enableFog: this._enableFogToggle.isChecked
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
9
assets/scripts/FlashLightEffectScene.ts.meta
Normal file
9
assets/scripts/FlashLightEffectScene.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.5",
|
||||||
|
"uuid": "6d3aff77-2683-4417-8960-2a5fd5d0757c",
|
||||||
|
"isPlugin": false,
|
||||||
|
"loadPluginInWeb": true,
|
||||||
|
"loadPluginInNative": true,
|
||||||
|
"loadPluginInEditor": false,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
@@ -2,7 +2,7 @@ const { ccclass, property } = cc._decorator;
|
|||||||
|
|
||||||
@ccclass
|
@ccclass
|
||||||
export default class PointLightCtrlComponent extends cc.Component {
|
export default class PointLightCtrlComponent extends cc.Component {
|
||||||
private _localDiffusionUniform: PointLightUniform = new PointLightUniform();
|
private _pointLightUBO: PointLightUBO = new PointLightUBO();
|
||||||
|
|
||||||
onEnable() {
|
onEnable() {
|
||||||
this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchStart, this);
|
this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchStart, this);
|
||||||
@@ -26,7 +26,7 @@ export default class PointLightCtrlComponent extends cc.Component {
|
|||||||
|
|
||||||
// 将触摸点转换为OPENGL坐标系并归一化
|
// 将触摸点转换为OPENGL坐标系并归一化
|
||||||
// OpenGl 坐标系原点在左上角
|
// OpenGl 坐标系原点在左上角
|
||||||
this._localDiffusionUniform.certerPoint = cc.v2(
|
this._pointLightUBO.centerPoint = cc.v2(
|
||||||
this.node.anchorX + touchPointInNodeSpace.x / this.node.width,
|
this.node.anchorX + touchPointInNodeSpace.x / this.node.width,
|
||||||
1 - (this.node.anchorY + touchPointInNodeSpace.y / this.node.height)
|
1 - (this.node.anchorY + touchPointInNodeSpace.y / this.node.height)
|
||||||
);
|
);
|
||||||
@@ -34,28 +34,28 @@ export default class PointLightCtrlComponent extends cc.Component {
|
|||||||
this._updateMaterial();
|
this._updateMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onPropertyChange(localDiffusionUniform: PointLightUniform) {
|
private _onPropertyChange(pointLightUBO: PointLightUBO) {
|
||||||
this._localDiffusionUniform.centerColor = localDiffusionUniform.centerColor;
|
this._pointLightUBO.centerColor = pointLightUBO.centerColor;
|
||||||
this._localDiffusionUniform.radius = localDiffusionUniform.radius;
|
this._pointLightUBO.radius = pointLightUBO.radius;
|
||||||
this._localDiffusionUniform.cropAlpha = localDiffusionUniform.cropAlpha;
|
this._pointLightUBO.cropAlpha = pointLightUBO.cropAlpha;
|
||||||
this._localDiffusionUniform.enableFog = localDiffusionUniform.enableFog;
|
this._pointLightUBO.enableFog = pointLightUBO.enableFog;
|
||||||
this._updateMaterial();
|
this._updateMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _updateMaterial() {
|
private _updateMaterial() {
|
||||||
this.getComponents(cc.RenderComponent).forEach(renderComponent => {
|
this.getComponents(cc.RenderComponent).forEach(renderComponent => {
|
||||||
let material: cc.Material = renderComponent.getMaterial(0);
|
let material: cc.Material = renderComponent.getMaterial(0);
|
||||||
material.setProperty("centerColor", this._localDiffusionUniform.centerColor);
|
material.setProperty("centerColor", this._pointLightUBO.centerColor);
|
||||||
material.setProperty("centerPoint", this._localDiffusionUniform.certerPoint);
|
material.setProperty("centerPoint", this._pointLightUBO.centerPoint);
|
||||||
material.setProperty("radius", this._localDiffusionUniform.radius);
|
material.setProperty("radius", this._pointLightUBO.radius);
|
||||||
material.setProperty("cropAlpha", this._localDiffusionUniform.cropAlpha);
|
material.setProperty("cropAlpha", this._pointLightUBO.cropAlpha);
|
||||||
material.setProperty("enableFog", this._localDiffusionUniform.enableFog);
|
material.setProperty("enableFog", this._pointLightUBO.enableFog);
|
||||||
renderComponent.setMaterial(0, material);
|
renderComponent.setMaterial(0, material);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PointLightUniform {
|
export class PointLightUBO {
|
||||||
/**
|
/**
|
||||||
* 中心点颜色
|
* 中心点颜色
|
||||||
*/
|
*/
|
||||||
@@ -64,7 +64,7 @@ export class PointLightUniform {
|
|||||||
/**
|
/**
|
||||||
* 中心点坐标 ([0.0, 1.0], [0.0, 1.0])
|
* 中心点坐标 ([0.0, 1.0], [0.0, 1.0])
|
||||||
*/
|
*/
|
||||||
certerPoint: cc.Vec2 = cc.v2(0.5, 0.5);
|
centerPoint: cc.Vec2 = cc.v2(0.5, 0.5);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扩散半径 [0.0, 1.0]
|
* 扩散半径 [0.0, 1.0]
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import PointLightCtrlComponent, { PointLightUniform } from "./PointLightCtrlComponent";
|
import PointLightCtrlComponent, { PointLightUBO } from "./PointLightCtrlComponent";
|
||||||
|
|
||||||
const { ccclass, property } = cc._decorator;
|
const { ccclass, property } = cc._decorator;
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ export default class PointLightEffectScene extends cc.Component {
|
|||||||
|
|
||||||
// 通知子节点更新材质
|
// 通知子节点更新材质
|
||||||
this._examplesParentNode.children.forEach(childNode => {
|
this._examplesParentNode.children.forEach(childNode => {
|
||||||
childNode.emit("on_property_change", <PointLightUniform>{
|
childNode.emit("on_property_change", <PointLightUBO>{
|
||||||
centerColor: cc.color(
|
centerColor: cc.color(
|
||||||
Math.round(255 * this._redSlider.progress),
|
Math.round(255 * this._redSlider.progress),
|
||||||
Math.round(255 * this._greenSlider.progress),
|
Math.round(255 * this._greenSlider.progress),
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
const { ccclass, property } = cc._decorator;
|
const { ccclass, property } = cc._decorator;
|
||||||
|
|
||||||
@ccclass
|
@ccclass
|
||||||
export default class RoundCornerCropEffectScene extends cc.Component {
|
export default class RoundCornerCropV1EffectScene extends cc.Component {
|
||||||
private _roundCornerRadiuSlider: cc.Slider = null;
|
private _radiuSlider: cc.Slider = null;
|
||||||
private _roundCornerRadiuLabel: cc.Label = null;
|
private _radiuLabel: cc.Label = null;
|
||||||
|
|
||||||
private _examplesParentNode: cc.Node = null;
|
private _examplesParentNode: cc.Node = null;
|
||||||
|
|
||||||
@@ -11,18 +11,18 @@ export default class RoundCornerCropEffectScene extends cc.Component {
|
|||||||
// 关闭动态合图
|
// 关闭动态合图
|
||||||
cc.dynamicAtlasManager.enabled = false;
|
cc.dynamicAtlasManager.enabled = false;
|
||||||
|
|
||||||
this._roundCornerRadiuSlider = cc.find("Canvas/Content/Sliders/RoundCornerRadiusSlider/Slider").getComponent(cc.Slider);
|
this._radiuSlider = cc.find("Canvas/Content/Controller/RadiusSlider/Slider").getComponent(cc.Slider);
|
||||||
this._roundCornerRadiuLabel = cc.find("Canvas/Content/Sliders/RoundCornerRadiusSlider/ValueLabel").getComponent(cc.Label);
|
this._radiuLabel = cc.find("Canvas/Content/Controller/RadiusSlider/ValueLabel").getComponent(cc.Label);
|
||||||
|
|
||||||
this._examplesParentNode = cc.find("Canvas/Content/Examples");
|
this._examplesParentNode = cc.find("Canvas/Content/Examples");
|
||||||
}
|
}
|
||||||
|
|
||||||
onEnable() {
|
onEnable() {
|
||||||
this._roundCornerRadiuSlider.node.on("slide", this._onSliderChanged, this);
|
this._radiuSlider.node.on("slide", this._onSliderChanged, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
onDisable() {
|
onDisable() {
|
||||||
this._roundCornerRadiuSlider.node.off("slide", this._onSliderChanged, this);
|
this._radiuSlider.node.off("slide", this._onSliderChanged, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
@@ -30,11 +30,11 @@ export default class RoundCornerCropEffectScene extends cc.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _onSliderChanged() {
|
private _onSliderChanged() {
|
||||||
this._roundCornerRadiuLabel.string = `${this._roundCornerRadiuSlider.progress.toFixed(2)}`;
|
this._radiuLabel.string = `${this._radiuSlider.progress.toFixed(2)}`;
|
||||||
|
|
||||||
// 更新材质
|
// 更新材质
|
||||||
this._updateRenderComponentMaterial({
|
this._updateRenderComponentMaterial({
|
||||||
roundCornerRadius: this._roundCornerRadiuSlider.progress
|
radius: this._radiuSlider.progress
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,12 +49,12 @@ export default class RoundCornerCropEffectScene extends cc.Component {
|
|||||||
/**
|
/**
|
||||||
* 圆角半径 [0.0, 0.5] ,0.5 表示圆形裁剪
|
* 圆角半径 [0.0, 0.5] ,0.5 表示圆形裁剪
|
||||||
*/
|
*/
|
||||||
roundCornerRadius: number;
|
radius: number;
|
||||||
}) {
|
}) {
|
||||||
this._examplesParentNode.children.forEach(childNode => {
|
this._examplesParentNode.children.forEach(childNode => {
|
||||||
childNode.getComponents(cc.RenderComponent).forEach(renderComponent => {
|
childNode.getComponents(cc.RenderComponent).forEach(renderComponent => {
|
||||||
let material: cc.Material = renderComponent.getMaterial(0);
|
let material: cc.Material = renderComponent.getMaterial(0);
|
||||||
material.setProperty("roundCornerRadius", param.roundCornerRadius);
|
material.setProperty("radius", param.radius);
|
||||||
renderComponent.setMaterial(0, material);
|
renderComponent.setMaterial(0, material);
|
||||||
});
|
});
|
||||||
});
|
});
|
9
assets/scripts/RoundCornerCropV1EffectScene.ts.meta
Normal file
9
assets/scripts/RoundCornerCropV1EffectScene.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.5",
|
||||||
|
"uuid": "d27658c5-a966-4e50-a162-09c7af01579e",
|
||||||
|
"isPlugin": false,
|
||||||
|
"loadPluginInWeb": true,
|
||||||
|
"loadPluginInNative": true,
|
||||||
|
"loadPluginInEditor": false,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
80
assets/scripts/RoundCornerCropV2EffectScene.ts
Normal file
80
assets/scripts/RoundCornerCropV2EffectScene.ts
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
const { ccclass, property } = cc._decorator;
|
||||||
|
|
||||||
|
@ccclass
|
||||||
|
export default class RoundCornerCropV2EffectScene extends cc.Component {
|
||||||
|
private _radiuSlider: cc.Slider = null;
|
||||||
|
private _radiuLabel: cc.Label = null;
|
||||||
|
|
||||||
|
private _examplesParentNode: cc.Node = null;
|
||||||
|
|
||||||
|
onLoad() {
|
||||||
|
// 关闭动态合图
|
||||||
|
cc.dynamicAtlasManager.enabled = false;
|
||||||
|
|
||||||
|
this._radiuSlider = cc.find("Canvas/Content/Controller/RadiusSlider/Slider").getComponent(cc.Slider);
|
||||||
|
this._radiuLabel = cc.find("Canvas/Content/Controller/RadiusSlider/ValueLabel").getComponent(cc.Label);
|
||||||
|
|
||||||
|
this._examplesParentNode = cc.find("Canvas/Content/Examples");
|
||||||
|
}
|
||||||
|
|
||||||
|
onEnable() {
|
||||||
|
this._radiuSlider.node.on("slide", this._onSliderChanged, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
onDisable() {
|
||||||
|
this._radiuSlider.node.off("slide", this._onSliderChanged, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
this._onSliderChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _onSliderChanged() {
|
||||||
|
// 计算半径px
|
||||||
|
let radiusInPx = Math.floor(100 * this._radiuSlider.progress);
|
||||||
|
this._radiuLabel.string = radiusInPx + "";
|
||||||
|
|
||||||
|
// 更新材质
|
||||||
|
this._updateRenderComponentMaterial({
|
||||||
|
radiusInPx: radiusInPx
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新渲染组件的材质
|
||||||
|
*
|
||||||
|
* 1. 获取材质
|
||||||
|
* 2. 给材质的 unitform 变量赋值
|
||||||
|
* 3. 重新将材质赋值回去
|
||||||
|
*/
|
||||||
|
private _updateRenderComponentMaterial(param: {
|
||||||
|
/**
|
||||||
|
* 圆角半径px
|
||||||
|
*/
|
||||||
|
radiusInPx: number;
|
||||||
|
}) {
|
||||||
|
this._examplesParentNode.children.forEach(childNode => {
|
||||||
|
childNode.getComponents(cc.RenderComponent).forEach(renderComponent => {
|
||||||
|
// 计算半径px分别相对于纹理宽高的比例(也叫归一化)
|
||||||
|
let xRadiux = param.radiusInPx / childNode.width;
|
||||||
|
// 约束范围在区间 [0.0, 0.5]
|
||||||
|
xRadiux = xRadiux >= 0.5 ? 0.5 : xRadiux;
|
||||||
|
|
||||||
|
let yRadius = param.radiusInPx / childNode.height;
|
||||||
|
yRadius = yRadius >= 0.5 ? 0.5 : yRadius;
|
||||||
|
|
||||||
|
if (childNode.name === "Rectangle1") cc.log(`${childNode.name} : (${xRadiux}, ${yRadius})`);
|
||||||
|
|
||||||
|
// 更新材质
|
||||||
|
let material: cc.Material = renderComponent.getMaterial(0);
|
||||||
|
|
||||||
|
// 圆角x轴半径长度(相对于纹理宽度)[0.0, 0.5]
|
||||||
|
material.setProperty("xRadius", xRadiux);
|
||||||
|
|
||||||
|
// 圆角y轴半径长度(相对于纹理高度)[0.0, 0.5]
|
||||||
|
material.setProperty("yRadius", yRadius);
|
||||||
|
renderComponent.setMaterial(0, material);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
9
assets/scripts/RoundCornerCropV2EffectScene.ts.meta
Normal file
9
assets/scripts/RoundCornerCropV2EffectScene.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.5",
|
||||||
|
"uuid": "24bbe7ba-5d1e-42d9-b2dd-f219fef90367",
|
||||||
|
"isPlugin": false,
|
||||||
|
"loadPluginInWeb": true,
|
||||||
|
"loadPluginInNative": true,
|
||||||
|
"loadPluginInEditor": false,
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
BIN
static/effects/2d-sprite-flash-light.gif
Normal file
BIN
static/effects/2d-sprite-flash-light.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 MiB |
BIN
static/effects/2d-sprite-round-corner-crop-v1.gif
Normal file
BIN
static/effects/2d-sprite-round-corner-crop-v1.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 323 KiB |
BIN
static/effects/2d-sprite-round-corner-crop-v2.gif
Normal file
BIN
static/effects/2d-sprite-round-corner-crop-v2.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 434 KiB |
Binary file not shown.
Before Width: | Height: | Size: 267 KiB |
Reference in New Issue
Block a user