[add] First

This commit is contained in:
2022-07-25 11:11:37 +08:00
commit 0b3011e6ef
75 changed files with 29513 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
//高斯模糊效果(在华为P6上不生效)
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
u_degree: { value: 0.03 }
u_brightness: { value: 1.0 }
}%
CCProgram vs %{ // 顶点Shader模块开始
#include <cc-global>
precision highp float; //定义float高精度
in vec3 a_position; // 顶点Shader 从渲染管道里面获取的顶点信息,使用attribute来修饰;
in vec2 a_uv0; // 纹理坐标;
out vec2 uv0; // 传递给着色Shadervarying 来修饰,进行插值
void main () {
gl_Position = cc_matViewProj * vec4(a_position, 1);
uv0 = a_uv0;
}
}%
CCProgram fs %{
#define repeats 5. //重复次数,值越大模糊质量越高,但性能越低
precision highp float;
in vec2 uv0;
uniform sampler2D texture;
uniform ARGS{
float u_degree; //模糊度,外界属性
float u_brightness; //亮度,外界属性
};
// 应用贴图UV
vec4 draw(vec2 uv) {
return texture2D(texture,uv).rgba;
}
float grid(float var, float size) {
return floor(var*size)/size;
}
// 降低亮度
vec4 dim(vec4 col, float factor) {
return vec4(col.r * factor, col.g * factor, col.b * factor, col.a);
}
// 随机值
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
void main()
{
// 模糊贴图
vec4 blurred_image = vec4(0.);
// 重复采样
for (float i = 0.; i < repeats; i++) {
// 第一采样点
vec2 q = vec2(cos(degrees((i/repeats)*360.)),sin(degrees((i/repeats)*360.))) * (rand(vec2(i,uv0.x+uv0.y))+u_degree);
vec2 uv2 = uv0+(q*u_degree);
blurred_image += draw(uv2)/2.;
// 第二采样点
q = vec2(cos(degrees((i/repeats)*360.)),sin(degrees((i/repeats)*360.))) * (rand(vec2(i+2.,uv0.x+uv0.y+24.))+u_degree);
uv2 = uv0+(q*u_degree);
blurred_image += draw(uv2)/2.;
}
// 中和
blurred_image /= repeats;
// 降低亮度
blurred_image = dim(blurred_image, u_brightness);
// 导出颜色
gl_FragColor = vec4(blurred_image);
}
}%

View File

@@ -0,0 +1,17 @@
{
"ver": "1.0.25",
"uuid": "d64b960e-910a-4f6a-a413-b37932350ea6",
"compiledShaders": [
{
"glsl1": {
"vert": "uniform mat4 cc_matViewProj;\nprecision highp float;\nattribute vec3 a_position;\nattribute vec2 a_uv0;\nvarying vec2 uv0;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n uv0 = a_uv0;\n}",
"frag": "\nprecision highp float;\nvarying vec2 uv0;\nuniform sampler2D texture;\nuniform float u_degree;\nuniform float u_brightness;\nvec4 draw(vec2 uv) {\n return texture2D(texture,uv).rgba;\n}\nvec4 dim(vec4 col, float factor) {\n return vec4(col.r * factor, col.g * factor, col.b * factor, col.a);\n}\nfloat rand(vec2 co){\n return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\nvoid main()\n{\n vec4 blurred_image = vec4(0.);\n for (float i = 0.; i < 5.; i++) {\n vec2 q = vec2(cos(degrees((i/5.)*360.)),sin(degrees((i/5.)*360.))) * (rand(vec2(i,uv0.x+uv0.y))+u_degree);\n vec2 uv2 = uv0+(q*u_degree);\n blurred_image += draw(uv2)/2.;\n q = vec2(cos(degrees((i/5.)*360.)),sin(degrees((i/5.)*360.))) * (rand(vec2(i+2.,uv0.x+uv0.y+24.))+u_degree);\n uv2 = uv0+(q*u_degree);\n blurred_image += draw(uv2)/2.;\n }\n blurred_image /= 5.;\n blurred_image = dim(blurred_image, u_brightness);\n gl_FragColor = vec4(blurred_image);\n}"
},
"glsl3": {
"vert": "uniform CCGlobal {\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 vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nprecision highp float;\nin vec3 a_position;\nin vec2 a_uv0;\nout vec2 uv0;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n uv0 = a_uv0;\n}",
"frag": "\nprecision highp float;\nin vec2 uv0;\nuniform sampler2D texture;\nuniform ARGS{\n float u_degree;\n float u_brightness;\n};\nvec4 draw(vec2 uv) {\n return texture2D(texture,uv).rgba;\n}\nvec4 dim(vec4 col, float factor) {\n return vec4(col.r * factor, col.g * factor, col.b * factor, col.a);\n}\nfloat rand(vec2 co){\n return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\nvoid main()\n{\n vec4 blurred_image = vec4(0.);\n for (float i = 0.; i < 5.; i++) {\n vec2 q = vec2(cos(degrees((i/5.)*360.)),sin(degrees((i/5.)*360.))) * (rand(vec2(i,uv0.x+uv0.y))+u_degree);\n vec2 uv2 = uv0+(q*u_degree);\n blurred_image += draw(uv2)/2.;\n q = vec2(cos(degrees((i/5.)*360.)),sin(degrees((i/5.)*360.))) * (rand(vec2(i+2.,uv0.x+uv0.y+24.))+u_degree);\n uv2 = uv0+(q*u_degree);\n blurred_image += draw(uv2)/2.;\n }\n blurred_image /= 5.;\n blurred_image = dim(blurred_image, u_brightness);\n gl_FragColor = vec4(blurred_image);\n}"
}
}
],
"subMetas": {}
}

View File

@@ -0,0 +1,58 @@
//高斯模糊2
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
u_resolution: { value: [1280,720] }
}%
CCProgram vs %{
#include <cc-global>
precision highp float; // 定义float高精度
in vec3 a_position; // 顶点Shader 从渲染管道里面获取的顶点信息,使用attribute来修饰;
in vec2 a_uv0; // 纹理坐标;
out vec2 uv0; // 传递给着色Shadervarying 来修饰,进行插值
void main () {
vec4 pos = cc_matViewProj * vec4(a_position, 1);
gl_Position = pos;
uv0 = a_uv0;
}
}%
CCProgram fs %{
precision mediump float;
in vec2 uv0;
uniform sampler2D texture;
uniform ARGS {
vec2 u_resolution;
float strength;
};
const float blurRadius = 7.0;
void main()
{
vec2 unit = 1.0 / u_resolution; //单位坐标
vec3 sumColor = vec3(0.0, 0.0, 0.0);
float count = 0.0;
vec4 col = vec4(0.0);
for(float fy = -blurRadius; fy <= blurRadius; ++fy)
{
for(float fx = -blurRadius; fx <= blurRadius; ++fx)
{
float weight = (blurRadius - abs(fx)) * (blurRadius - abs(fy)); //权重p点的权重最高向四周依次减少
col += texture2D(texture, uv0 + vec2(fx * unit.x, fy * unit.y)) * weight;
count += weight;
}
}
col.a = texture2D(texture, uv0).a;
gl_FragColor = vec4(col.rgb / count, col.a);
}
}%

View File

@@ -0,0 +1,17 @@
{
"ver": "1.0.25",
"uuid": "14e64f7c-87c8-459a-ad37-6c773ceea4e6",
"compiledShaders": [
{
"glsl1": {
"vert": "uniform mat4 cc_matViewProj;\nprecision highp float;\nattribute vec3 a_position;\nattribute vec2 a_uv0;\nvarying vec2 uv0;\nvoid main () {\n vec4 pos = cc_matViewProj * vec4(a_position, 1);\n gl_Position = pos;\n uv0 = a_uv0;\n}",
"frag": "\nprecision mediump float;\nvarying vec2 uv0;\nuniform sampler2D texture;\nuniform vec2 u_resolution;\nconst float blurRadius = 7.0;\nvoid main()\n{\n vec2 unit = 1.0 / u_resolution;\n vec3 sumColor = vec3(0.0, 0.0, 0.0);\n float count = 0.0;\n vec4 col = vec4(0.0);\n for(float fy = -blurRadius; fy <= blurRadius; ++fy)\n {\n for(float fx = -blurRadius; fx <= blurRadius; ++fx)\n {\n float weight = (blurRadius - abs(fx)) * (blurRadius - abs(fy));\n col += texture2D(texture, uv0 + vec2(fx * unit.x, fy * unit.y)) * weight;\n count += weight;\n }\n }\n col.a = texture2D(texture, uv0).a;\n gl_FragColor = vec4(col.rgb / count, col.a);\n}"
},
"glsl3": {
"vert": "uniform CCGlobal {\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 vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nprecision highp float;\nin vec3 a_position;\nin vec2 a_uv0;\nout vec2 uv0;\nvoid main () {\n vec4 pos = cc_matViewProj * vec4(a_position, 1);\n gl_Position = pos;\n uv0 = a_uv0;\n}",
"frag": "\nprecision mediump float;\nin vec2 uv0;\nuniform sampler2D texture;\nuniform ARGS {\n vec2 u_resolution;\n float strength;\n};\nconst float blurRadius = 7.0;\nvoid main()\n{\n vec2 unit = 1.0 / u_resolution;\n vec3 sumColor = vec3(0.0, 0.0, 0.0);\n float count = 0.0;\n vec4 col = vec4(0.0);\n for(float fy = -blurRadius; fy <= blurRadius; ++fy)\n {\n for(float fx = -blurRadius; fx <= blurRadius; ++fx)\n {\n float weight = (blurRadius - abs(fx)) * (blurRadius - abs(fy));\n col += texture2D(texture, uv0 + vec2(fx * unit.x, fy * unit.y)) * weight;\n count += weight;\n }\n }\n col.a = texture2D(texture, uv0).a;\n gl_FragColor = vec4(col.rgb / count, col.a);\n}"
}
}
],
"subMetas": {}
}

View File

@@ -0,0 +1,56 @@
//溶解特效
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
u_time: { value: 1.0 }
}%
CCProgram vs %{
#include <cc-global>
precision highp float;
in vec3 a_position;
in vec2 a_uv0;
out vec2 uv0;
void main () {
gl_Position = cc_matViewProj * vec4(a_position, 1);
uv0 = a_uv0;
}
}%
CCProgram fs %{
precision highp float; //定义高精度
uniform sampler2D texture; //纹理
uniform ARGS {
//时间 根据时间计算需要丢弃的像素颜色值范围,也就是溶解的范围
float u_time;
};
in vec2 uv0;
void main()
{
float time = u_time;
vec4 c = texture2D(texture,uv0);
float height = c.g;
if(height < time)
{
//丢弃像素,相当于溶解效果
discard;
}
if(height < time + 0.1) {
//这里可以对溶解边缘进行一些处理,比如透明度减少等
c.a = c.a-0.1;
}
//给片元(像素)赋值
gl_FragColor = c;
}
}%

View File

@@ -0,0 +1,17 @@
{
"ver": "1.0.25",
"uuid": "ed4b64c1-0535-4ae5-9648-4acb0a4c0fd8",
"compiledShaders": [
{
"glsl1": {
"vert": "uniform mat4 cc_matViewProj;\nprecision highp float;\n attribute vec3 a_position;\n attribute vec2 a_uv0;\n varying vec2 uv0;\n void main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n uv0 = a_uv0;\n }",
"frag": "\nprecision highp float;\nuniform sampler2D texture;\nuniform float u_time;\nvarying vec2 uv0;\nvoid main()\n{\n float time = u_time;\n vec4 c = texture2D(texture,uv0);\n float height = c.g;\n if(height < time)\n {\n discard;\n }\n if(height < time + 0.1) {\n c.a = c.a-0.1;\n }\n gl_FragColor = c;\n}"
},
"glsl3": {
"vert": "uniform CCGlobal {\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 vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nprecision highp float;\n in vec3 a_position;\n in vec2 a_uv0;\n out vec2 uv0;\n void main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n uv0 = a_uv0;\n }",
"frag": "\nprecision highp float;\nuniform sampler2D texture;\nuniform ARGS {\n float u_time;\n};\nin vec2 uv0;\nvoid main()\n{\n float time = u_time;\n vec4 c = texture2D(texture,uv0);\n float height = c.g;\n if(height < time)\n {\n discard;\n }\n if(height < time + 0.1) {\n c.a = c.a-0.1;\n }\n gl_FragColor = c;\n}"
}
}
],
"subMetas": {}
}

View File

@@ -0,0 +1,182 @@
//外发光效果
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
u_edge: { value: 0.5 }
u_offset: { value: 0.01 }
u_edgeBlur: { value: 0.01 }
u_mixColor: { value: [1, 1, 1, 1], inspector: { type: color } }
u_edgeColor: { value: [1, 1, 1, 0], inspector: { type: color } }
}%
CCProgram vs %{
#include <cc-global>
precision highp float;
in vec4 a_position;
in vec2 a_uv0;
out vec2 uv0;
void main()
{
gl_Position = cc_matViewProj * a_position;
uv0 = a_uv0;
}
}%
CCProgram fs %{
precision highp float;
in vec2 uv0;
uniform sampler2D texture;
uniform ARGS{
vec4 u_mixColor;
float u_edge;
};
// 是否边缘羽化
#if IS_Edge_Blur
uniform ARGS1{
float u_edgeBlur;
};
#endif
// 是否边缘发光(不要和羽化一起使用,会有边)
#if IS_EdgeGlowing
uniform ARGS2{
float u_offset;
};
#endif
// 是否使用边缘颜色
#if USE_EDGE_COLOR
uniform ARGS3{
vec4 u_edgeColor;
};
#endif
// 应用贴图颜色 画圆
vec4 drawCircle() {
float edge = u_edge;
float dis = 0.0;
float offset = 0.0;
vec2 uv = uv0;
// 是否边缘发光
#if IS_EdgeGlowing
offset = u_offset;
uv = vec2(0.5 + (uv0.x - 0.5) * ((offset*2.0) + 1.0), 0.5 + (uv0.y - 0.5) * ((offset*2.0) + 1.0));
#endif
if ( uv.x < edge )
{
if ( uv.y < edge )
{
dis = distance( uv, vec2(edge, edge) );
}
if ( uv.y > (1.0 - edge) )
{
dis = distance( uv, vec2(edge, (1.0 - edge)) );
}
}
else if ( uv.x > (1.0 - edge) )
{
if ( uv.y < edge )
{
dis = distance( uv, vec2((1.0 - edge), edge ) );
}
if ( uv.y > (1.0 - edge) )
{
dis = distance( uv, vec2((1.0 - edge), (1.0 - edge) ) );
}
}
// 混合外边颜色
vec4 color = u_mixColor * texture2D(texture,uv);
// 边缘颜色
vec4 edge_color = color;
// 边缘羽化,默认0.01,减少抗锯齿
float blur = 0.0;
// 是否边缘羽化
#if IS_Edge_Blur
blur = u_edgeBlur;
#endif
// 如果有外部颜色,重新定义 边缘颜色
#if USE_EDGE_COLOR
// 如果应用贴图颜色混合
#if USER_TEXTURE_COLOR
edge_color = u_edgeColor * texture2D(texture,uv);
#else
edge_color = u_edgeColor;
#endif
#endif
if(dis > 0.001)
{
// 外圈沟
float gap = edge * blur;
if(dis <= edge - gap)
{
color = color;
}
else if(dis <= edge)
{
// 平滑过渡: ret smoothstep(a, b, x) 可以用来生成0到1的平滑过渡.
float t = smoothstep(0.,gap,edge-dis);
// 边缘颜色和透明度
color = vec4(edge_color.rgb,t * edge_color.a);
}else{
// 隐藏不要的部分
// 是否边缘发光
#if IS_EdgeGlowing
color = vec4(edge_color.rgb, (offset - (dis - edge))/offset);
#else
color = vec4(edge_color.rgb,0.);
#endif
}
}
else
{
// 是否边缘发光
#if IS_EdgeGlowing
float absX = abs(uv.x - 0.5);
if(absX > 0.5)
{
color = vec4( edge_color.rgb, (offset - (absX - 0.5))/offset);
}
else
{
float absY = abs(uv.y - 0.5);
if (absY > 0.5){
color = vec4( edge_color.rgb, (offset - (absX - 0.5))/offset);
}
else{
color = color;
}
}
#else
color = color;
#endif
}
return color;
}
void main()
{
vec4 color = drawCircle();
gl_FragColor = color;
}
}%

View File

@@ -0,0 +1,17 @@
{
"ver": "1.0.25",
"uuid": "0f9457ac-e49b-4ec4-bd74-11b0eabbdb4d",
"compiledShaders": [
{
"glsl1": {
"vert": "uniform mat4 cc_matViewProj;\nprecision highp float;\nattribute vec4 a_position;\nattribute vec2 a_uv0;\nvarying vec2 uv0;\nvoid main()\n{\n gl_Position = cc_matViewProj * a_position;\n uv0 = a_uv0;\n}",
"frag": "\n precision highp float;\n varying vec2 uv0;\n uniform sampler2D texture;\n uniform vec4 u_mixColor;\nuniform float u_edge;\n#if IS_Edge_Blur\n uniform float u_edgeBlur;\n#endif\n#if IS_EdgeGlowing\n uniform float u_offset;\n#endif\n#if USE_EDGE_COLOR\n uniform vec4 u_edgeColor;\n#endif\nvec4 drawCircle() {\n float edge = u_edge;\n float dis = 0.0;\n float offset = 0.0;\n vec2 uv = uv0;\n#if IS_EdgeGlowing\n offset = u_offset;\n uv = vec2(0.5 + (uv0.x - 0.5) * ((offset*2.0) + 1.0), 0.5 + (uv0.y - 0.5) * ((offset*2.0) + 1.0));\n#endif\n if ( uv.x < edge )\n {\n if ( uv.y < edge )\n {\n dis = distance( uv, vec2(edge, edge) );\n }\n if ( uv.y > (1.0 - edge) )\n {\n dis = distance( uv, vec2(edge, (1.0 - edge)) );\n }\n }\n else if ( uv.x > (1.0 - edge) )\n {\n if ( uv.y < edge )\n {\n dis = distance( uv, vec2((1.0 - edge), edge ) );\n }\n if ( uv.y > (1.0 - edge) )\n {\n dis = distance( uv, vec2((1.0 - edge), (1.0 - edge) ) );\n }\n }\n vec4 color = u_mixColor * texture2D(texture,uv);\n vec4 edge_color = color;\n float blur = 0.0;\n #if IS_Edge_Blur\n blur = u_edgeBlur;\n #endif\n #if USE_EDGE_COLOR\n #if USER_TEXTURE_COLOR\n edge_color = u_edgeColor * texture2D(texture,uv);\n #else\n edge_color = u_edgeColor;\n #endif\n #endif\n if(dis > 0.001)\n {\n float gap = edge * blur;\n if(dis <= edge - gap)\n {\n color = color;\n }\n else if(dis <= edge)\n {\n float t = smoothstep(0.,gap,edge-dis);\n color = vec4(edge_color.rgb,t * edge_color.a);\n }else{\n #if IS_EdgeGlowing\n color = vec4(edge_color.rgb, (offset - (dis - edge))/offset);\n #else\n color = vec4(edge_color.rgb,0.);\n #endif\n }\n }\n else\n {\n #if IS_EdgeGlowing\n float absX = abs(uv.x - 0.5);\n if(absX > 0.5)\n {\n color = vec4( edge_color.rgb, (offset - (absX - 0.5))/offset);\n }\n else\n {\n float absY = abs(uv.y - 0.5);\n if (absY > 0.5){\n color = vec4( edge_color.rgb, (offset - (absX - 0.5))/offset);\n }\n else{\n color = color;\n }\n }\n #else\n color = color;\n #endif\n }\n return color;\n}\n void main()\n {\n vec4 color = drawCircle();\n gl_FragColor = color;\n }"
},
"glsl3": {
"vert": "uniform CCGlobal {\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 vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nprecision highp float;\nin vec4 a_position;\nin vec2 a_uv0;\nout vec2 uv0;\nvoid main()\n{\n gl_Position = cc_matViewProj * a_position;\n uv0 = a_uv0;\n}",
"frag": "\n precision highp float;\n in vec2 uv0;\n uniform sampler2D texture;\n uniform ARGS{\n vec4 u_mixColor;\n float u_edge;\n };\n#if IS_Edge_Blur\n uniform ARGS1{\n float u_edgeBlur;\n };\n#endif\n#if IS_EdgeGlowing\n uniform ARGS2{\n float u_offset;\n };\n#endif\n#if USE_EDGE_COLOR\n uniform ARGS3{\n vec4 u_edgeColor;\n };\n#endif\nvec4 drawCircle() {\n float edge = u_edge;\n float dis = 0.0;\n float offset = 0.0;\n vec2 uv = uv0;\n#if IS_EdgeGlowing\n offset = u_offset;\n uv = vec2(0.5 + (uv0.x - 0.5) * ((offset*2.0) + 1.0), 0.5 + (uv0.y - 0.5) * ((offset*2.0) + 1.0));\n#endif\n if ( uv.x < edge )\n {\n if ( uv.y < edge )\n {\n dis = distance( uv, vec2(edge, edge) );\n }\n if ( uv.y > (1.0 - edge) )\n {\n dis = distance( uv, vec2(edge, (1.0 - edge)) );\n }\n }\n else if ( uv.x > (1.0 - edge) )\n {\n if ( uv.y < edge )\n {\n dis = distance( uv, vec2((1.0 - edge), edge ) );\n }\n if ( uv.y > (1.0 - edge) )\n {\n dis = distance( uv, vec2((1.0 - edge), (1.0 - edge) ) );\n }\n }\n vec4 color = u_mixColor * texture2D(texture,uv);\n vec4 edge_color = color;\n float blur = 0.0;\n #if IS_Edge_Blur\n blur = u_edgeBlur;\n #endif\n #if USE_EDGE_COLOR\n #if USER_TEXTURE_COLOR\n edge_color = u_edgeColor * texture2D(texture,uv);\n #else\n edge_color = u_edgeColor;\n #endif\n #endif\n if(dis > 0.001)\n {\n float gap = edge * blur;\n if(dis <= edge - gap)\n {\n color = color;\n }\n else if(dis <= edge)\n {\n float t = smoothstep(0.,gap,edge-dis);\n color = vec4(edge_color.rgb,t * edge_color.a);\n }else{\n #if IS_EdgeGlowing\n color = vec4(edge_color.rgb, (offset - (dis - edge))/offset);\n #else\n color = vec4(edge_color.rgb,0.);\n #endif\n }\n }\n else\n {\n #if IS_EdgeGlowing\n float absX = abs(uv.x - 0.5);\n if(absX > 0.5)\n {\n color = vec4( edge_color.rgb, (offset - (absX - 0.5))/offset);\n }\n else\n {\n float absY = abs(uv.y - 0.5);\n if (absY > 0.5){\n color = vec4( edge_color.rgb, (offset - (absX - 0.5))/offset);\n }\n else{\n color = color;\n }\n }\n #else\n color = color;\n #endif\n }\n return color;\n}\n void main()\n {\n vec4 color = drawCircle();\n gl_FragColor = color;\n }"
}
}
],
"subMetas": {}
}

View File

@@ -0,0 +1,48 @@
//马赛克
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
u_resolution: { value: [1280,720] }
u_mosaicSize: { value: 12 }
}%
CCProgram vs %{
#include <cc-global>
precision highp float;
in vec3 a_position;
in vec2 a_uv0;
out vec2 uv0;
void main () {
gl_Position = cc_matViewProj * vec4(a_position, 1);
uv0 = a_uv0;
}
}%
CCProgram fs %{
precision highp float;
in vec2 uv0;
uniform sampler2D texture;
uniform ARGS {
vec2 u_resolution;
float u_mosaicSize;
};
void main(void)
{
vec4 color;
vec2 xy = vec2(uv0.x * u_resolution.x, uv0.y * u_resolution.y);
vec2 xyMosaic = vec2(floor(xy.x / u_mosaicSize) * u_mosaicSize, floor(xy.y / u_mosaicSize) * u_mosaicSize);
vec2 uvMosaic = vec2(xyMosaic.x / u_resolution.x, xyMosaic.y / u_resolution.y);
color = texture2D( texture, uvMosaic);
gl_FragColor = color;
}
}%

View File

@@ -0,0 +1,17 @@
{
"ver": "1.0.25",
"uuid": "8b12cd41-6673-45b2-8e81-f77078e331b4",
"compiledShaders": [
{
"glsl1": {
"vert": "uniform mat4 cc_matViewProj;\nprecision highp float;\nattribute vec3 a_position;\nattribute vec2 a_uv0;\nvarying vec2 uv0;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n uv0 = a_uv0;\n}",
"frag": "\nprecision highp float;\nvarying vec2 uv0;\nuniform sampler2D texture;\nuniform vec2 u_resolution;\nuniform float u_mosaicSize;\nvoid main(void)\n{\n vec4 color;\n vec2 xy = vec2(uv0.x * u_resolution.x, uv0.y * u_resolution.y);\n vec2 xyMosaic = vec2(floor(xy.x / u_mosaicSize) * u_mosaicSize, floor(xy.y / u_mosaicSize) * u_mosaicSize);\n vec2 uvMosaic = vec2(xyMosaic.x / u_resolution.x, xyMosaic.y / u_resolution.y);\n color = texture2D( texture, uvMosaic);\n gl_FragColor = color;\n}"
},
"glsl3": {
"vert": "uniform CCGlobal {\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 vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nprecision highp float;\nin vec3 a_position;\nin vec2 a_uv0;\nout vec2 uv0;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n uv0 = a_uv0;\n}",
"frag": "\nprecision highp float;\nin vec2 uv0;\nuniform sampler2D texture;\nuniform ARGS {\n vec2 u_resolution;\n float u_mosaicSize;\n};\nvoid main(void)\n{\n vec4 color;\n vec2 xy = vec2(uv0.x * u_resolution.x, uv0.y * u_resolution.y);\n vec2 xyMosaic = vec2(floor(xy.x / u_mosaicSize) * u_mosaicSize, floor(xy.y / u_mosaicSize) * u_mosaicSize);\n vec2 uvMosaic = vec2(xyMosaic.x / u_resolution.x, xyMosaic.y / u_resolution.y);\n color = texture2D( texture, uvMosaic);\n gl_FragColor = color;\n}"
}
}
],
"subMetas": {}
}

View File

@@ -0,0 +1,60 @@
//径向模糊
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
u_point: { value: [0.5, 0.5] }
u_resolution: { value: [1280, 720] }
u_Strength: { value: 0.125 }
}%
CCProgram vs %{ // 顶点Shader模块开始
#include <cc-global>
precision highp float; //定义float高精度
in vec3 a_position; // 顶点Shader 从渲染管道里面获取的顶点信息,使用attribute来修饰;
in vec2 a_uv0; // 纹理坐标;
out vec2 uv0; // 传递给着色Shadervarying 来修饰,进行插值
void main () {
gl_Position = cc_matViewProj * vec4(a_position, 1);
uv0 = a_uv0;
}
}%
CCProgram fs %{
precision highp float;
in vec2 uv0;
uniform sampler2D texture;
uniform ARGS{
vec2 u_resolution;
vec2 u_point;
float u_Strength;
};
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// const float u_Strength = 0.125;
const int Samples = 64; //multiple of 2
vec2 uv = fragCoord.xy;
vec2 dir = (fragCoord.xy-u_point.xy);
vec4 color = vec4(0.0,0.0,0.0,0.0);
for (int i = 0; i < Samples; i += 2) //operating at 2 samples for better performance
{
color += texture2D(texture,uv+float(i)/float(Samples)*dir*u_Strength);
color += texture2D(texture,uv+float(i+1)/float(Samples)*dir*u_Strength);
}
fragColor = color/float(Samples);
}
void main(void)
{
mainImage(gl_FragColor, uv0);
}
}%

View File

@@ -0,0 +1,17 @@
{
"ver": "1.0.25",
"uuid": "9d24dc19-8d72-483a-903d-914ccf86f169",
"compiledShaders": [
{
"glsl1": {
"vert": "uniform mat4 cc_matViewProj;\nprecision highp float;\nattribute vec3 a_position;\nattribute vec2 a_uv0;\nvarying vec2 uv0;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n uv0 = a_uv0;\n}",
"frag": "\nprecision highp float;\nvarying vec2 uv0;\nuniform sampler2D texture;\nuniform vec2 u_point;\nuniform float u_Strength;\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord )\n{\n const int Samples = 64;\n vec2 uv = fragCoord.xy;\n vec2 dir = (fragCoord.xy-u_point.xy);\n vec4 color = vec4(0.0,0.0,0.0,0.0);\n for (int i = 0; i < Samples; i += 2)\n {\n color += texture2D(texture,uv+float(i)/float(Samples)*dir*u_Strength);\n color += texture2D(texture,uv+float(i+1)/float(Samples)*dir*u_Strength);\n }\n fragColor = color/float(Samples);\n}\nvoid main(void)\n{\n mainImage(gl_FragColor, uv0);\n}"
},
"glsl3": {
"vert": "uniform CCGlobal {\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 vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nprecision highp float;\nin vec3 a_position;\nin vec2 a_uv0;\nout vec2 uv0;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n uv0 = a_uv0;\n}",
"frag": "\nprecision highp float;\nin vec2 uv0;\nuniform sampler2D texture;\nuniform ARGS{\n vec2 u_resolution;\n vec2 u_point;\n float u_Strength;\n};\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord )\n{\n const int Samples = 64;\n vec2 uv = fragCoord.xy;\n vec2 dir = (fragCoord.xy-u_point.xy);\n vec4 color = vec4(0.0,0.0,0.0,0.0);\n for (int i = 0; i < Samples; i += 2)\n {\n color += texture2D(texture,uv+float(i)/float(Samples)*dir*u_Strength);\n color += texture2D(texture,uv+float(i+1)/float(Samples)*dir*u_Strength);\n }\n fragColor = color/float(Samples);\n}\nvoid main(void)\n{\n mainImage(gl_FragColor, uv0);\n}"
}
}
],
"subMetas": {}
}

View File

@@ -0,0 +1,72 @@
//水波纹效果
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
u_resolution: { value: [1280,720] }
u_time: { value: 1.0 }
}%
CCProgram vs %{ // 顶点Shader模块开始
#include <cc-global>
precision highp float; //定义float高精度
in vec3 a_position; // 顶点Shader 从渲染管道里面获取的顶点信息,使用attribute来修饰;
in vec2 a_uv0; // 纹理坐标;
out vec2 uv0; // 传递给着色Shadervarying 来修饰,进行插值
void main () {
gl_Position = cc_matViewProj * vec4(a_position, 1);
uv0 = a_uv0;
}
}%
CCProgram fs %{
precision highp float;
in vec2 uv0;
uniform sampler2D texture;
uniform ARGS {
vec4 UVoffset;
vec2 u_resolution;
float u_time;
float rotated;
};
#define F cos(x-y)*cos(y),sin(x+y)*sin(y)
vec2 s(vec2 p)
{
float d=u_time*0.2,x=8.*(p.x+d),y=8.*(p.y+d);
return vec2(F);
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// 换成resolution
vec2 rs = u_resolution.xy;
// 换成纹理坐标v_texCoord.xy
vec2 uv = fragCoord;
vec2 q = uv+2./u_resolution.x*(s(uv)-s(uv+rs));
//反转y
//q.y=1.-q.y;
fragColor = texture2D(texture, q);
}
void main()
{
vec2 UVnormalize;
UVnormalize.x = (uv0.x-UVoffset.x)/(UVoffset.z-UVoffset.x);
UVnormalize.y = (uv0.y-UVoffset.y)/(UVoffset.w-UVoffset.y);
if(rotated > 0.5)
{
float temp = UVnormalize.x;
UVnormalize.x = UVnormalize.y;
UVnormalize.y = 1.0 - temp;
}
mainImage(gl_FragColor, uv0.xy);
}
}%

View File

@@ -0,0 +1,17 @@
{
"ver": "1.0.25",
"uuid": "7d5495a0-26aa-4858-a9db-37507aff7ba4",
"compiledShaders": [
{
"glsl1": {
"vert": "uniform mat4 cc_matViewProj;\nprecision highp float;\nattribute vec3 a_position;\nattribute vec2 a_uv0;\nvarying vec2 uv0;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n uv0 = a_uv0;\n}",
"frag": "\nprecision highp float;\nvarying vec2 uv0;\nuniform sampler2D texture;\nuniform vec4 UVoffset;\nuniform vec2 u_resolution;\nuniform float u_time;\nuniform float rotated;\nvec2 s(vec2 p)\n{\n float d=u_time*0.2,x=8.*(p.x+d),y=8.*(p.y+d);\n return vec2(cos(x-y)*cos(y),sin(x+y)*sin(y));\n}\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord )\n{\n vec2 rs = u_resolution.xy;\n vec2 uv = fragCoord;\n vec2 q = uv+2./u_resolution.x*(s(uv)-s(uv+rs));\n fragColor = texture2D(texture, q);\n}\nvoid main()\n{\n vec2 UVnormalize;\n UVnormalize.x = (uv0.x-UVoffset.x)/(UVoffset.z-UVoffset.x);\n UVnormalize.y = (uv0.y-UVoffset.y)/(UVoffset.w-UVoffset.y);\n if(rotated > 0.5)\n {\n float temp = UVnormalize.x;\n UVnormalize.x = UVnormalize.y;\n UVnormalize.y = 1.0 - temp;\n }\n mainImage(gl_FragColor, uv0.xy);\n}"
},
"glsl3": {
"vert": "uniform CCGlobal {\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 vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nprecision highp float;\nin vec3 a_position;\nin vec2 a_uv0;\nout vec2 uv0;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n uv0 = a_uv0;\n}",
"frag": "\nprecision highp float;\nin vec2 uv0;\nuniform sampler2D texture;\nuniform ARGS {\n vec4 UVoffset;\n vec2 u_resolution;\n float u_time;\n float rotated;\n};\nvec2 s(vec2 p)\n{\n float d=u_time*0.2,x=8.*(p.x+d),y=8.*(p.y+d);\n return vec2(cos(x-y)*cos(y),sin(x+y)*sin(y));\n}\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord )\n{\n vec2 rs = u_resolution.xy;\n vec2 uv = fragCoord;\n vec2 q = uv+2./u_resolution.x*(s(uv)-s(uv+rs));\n fragColor = texture2D(texture, q);\n}\nvoid main()\n{\n vec2 UVnormalize;\n UVnormalize.x = (uv0.x-UVoffset.x)/(UVoffset.z-UVoffset.x);\n UVnormalize.y = (uv0.y-UVoffset.y)/(UVoffset.w-UVoffset.y);\n if(rotated > 0.5)\n {\n float temp = UVnormalize.x;\n UVnormalize.x = UVnormalize.y;\n UVnormalize.y = 1.0 - temp;\n }\n mainImage(gl_FragColor, uv0.xy);\n}"
}
}
],
"subMetas": {}
}

View File

@@ -0,0 +1,82 @@
//波纹流光
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
u_time: { value: 0.5 }
}%
CCProgram vs %{ // 顶点Shader模块开始
#include <cc-global>
precision highp float; //定义float高精度
in vec3 a_position; // 顶点Shader 从渲染管道里面获取的顶点信息,使用attribute来修饰;
in vec2 a_uv0; // 纹理坐标;
out vec2 uv0; // 传递给着色Shadervarying 来修饰,进行插值
void main () {
gl_Position = cc_matViewProj * vec4(a_position, 1);
uv0 = a_uv0;
}
}%
CCProgram fs %{
#define TAU 6.12
#define MAX_ITER 5
precision highp float;
in vec2 uv0;
uniform sampler2D texture;
uniform ARGS {
vec4 UVoffset;
float u_time;
float rotated;
};
void main()
{
float u_time = u_time * .5+5.;
vec2 UVnormalize;
UVnormalize.x = (uv0.x-UVoffset.x)/(UVoffset.z-UVoffset.x);
UVnormalize.y = (uv0.y-UVoffset.y)/(UVoffset.w-UVoffset.y);
if(rotated > 0.5)
{
float temp = UVnormalize.x;
UVnormalize.x = UVnormalize.y;
UVnormalize.y = 1.0 - temp;
}
vec2 uv = uv0.xy;//fragCoord.xy / iResolution.xy;
vec2 p = mod(uv*TAU, TAU)-250.0;
vec2 i = vec2(p);
float c = 1.0;
float inten = .0065;
for (int n = 0; n < MAX_ITER; n++)
{
float t = u_time * (1.0 - (3.5 / float(n+1)));
i = p + vec2(cos(t - i.x) + sin(t + i.y), sin(t - i.y) + cos(1.5*t + i.x));
c += 1.0/length(vec2(p.x / (cos(i.x+t)/inten),p.y / (cos(i.y+t)/inten)));
}
c /= float(MAX_ITER);
c = 1.17-pow(c, 1.4);
vec4 tex = texture2D(texture,uv0);
vec3 colour = vec3(pow(abs(c), 20.0));
colour = clamp(colour + vec3(0.0, 0.0, .0), 0.0, tex.a);
// 混合波光
float alpha = c*tex[3];
tex[0] = tex[0] + colour[0]*alpha;
tex[1] = tex[1] + colour[1]*alpha;
tex[2] = tex[2] + colour[2]*alpha;
gl_FragColor = vec4(1,1,1,1) * tex;
}
}%

View File

@@ -0,0 +1,17 @@
{
"ver": "1.0.25",
"uuid": "ae91e5d2-7d0a-41f4-a4fa-ffe0037ff8a0",
"compiledShaders": [
{
"glsl1": {
"vert": "uniform mat4 cc_matViewProj;\nprecision highp float;\nattribute vec3 a_position;\nattribute vec2 a_uv0;\nvarying vec2 uv0;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n uv0 = a_uv0;\n}",
"frag": "\nprecision highp float;\nvarying vec2 uv0;\nuniform sampler2D texture;\nuniform vec4 UVoffset;\nuniform float u_time;\nuniform float rotated;\nvoid main()\n{\n float u_time = u_time * .5+5.;\n vec2 UVnormalize;\n UVnormalize.x = (uv0.x-UVoffset.x)/(UVoffset.z-UVoffset.x);\n UVnormalize.y = (uv0.y-UVoffset.y)/(UVoffset.w-UVoffset.y);\n if(rotated > 0.5)\n {\n float temp = UVnormalize.x;\n UVnormalize.x = UVnormalize.y;\n UVnormalize.y = 1.0 - temp;\n }\n vec2 uv = uv0.xy;\n vec2 p = mod(uv*6.12, 6.12)-250.0;\n vec2 i = vec2(p);\n float c = 1.0;\n float inten = .0065;\n for (int n = 0; n < 5; n++)\n {\n float t = u_time * (1.0 - (3.5 / float(n+1)));\n i = p + vec2(cos(t - i.x) + sin(t + i.y), sin(t - i.y) + cos(1.5*t + i.x));\n c += 1.0/length(vec2(p.x / (cos(i.x+t)/inten),p.y / (cos(i.y+t)/inten)));\n }\n c /= float(5);\n c = 1.17-pow(c, 1.4);\n vec4 tex = texture2D(texture,uv0);\n vec3 colour = vec3(pow(abs(c), 20.0));\n colour = clamp(colour + vec3(0.0, 0.0, .0), 0.0, tex.a);\n float alpha = c*tex[3];\n tex[0] = tex[0] + colour[0]*alpha;\n tex[1] = tex[1] + colour[1]*alpha;\n tex[2] = tex[2] + colour[2]*alpha;\n gl_FragColor = vec4(1,1,1,1) * tex;\n}"
},
"glsl3": {
"vert": "uniform CCGlobal {\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 vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nprecision highp float;\nin vec3 a_position;\nin vec2 a_uv0;\nout vec2 uv0;\nvoid main () {\n gl_Position = cc_matViewProj * vec4(a_position, 1);\n uv0 = a_uv0;\n}",
"frag": "\nprecision highp float;\nin vec2 uv0;\nuniform sampler2D texture;\nuniform ARGS {\n vec4 UVoffset;\n float u_time;\n float rotated;\n};\nvoid main()\n{\n float u_time = u_time * .5+5.;\n vec2 UVnormalize;\n UVnormalize.x = (uv0.x-UVoffset.x)/(UVoffset.z-UVoffset.x);\n UVnormalize.y = (uv0.y-UVoffset.y)/(UVoffset.w-UVoffset.y);\n if(rotated > 0.5)\n {\n float temp = UVnormalize.x;\n UVnormalize.x = UVnormalize.y;\n UVnormalize.y = 1.0 - temp;\n }\n vec2 uv = uv0.xy;\n vec2 p = mod(uv*6.12, 6.12)-250.0;\n vec2 i = vec2(p);\n float c = 1.0;\n float inten = .0065;\n for (int n = 0; n < 5; n++)\n {\n float t = u_time * (1.0 - (3.5 / float(n+1)));\n i = p + vec2(cos(t - i.x) + sin(t + i.y), sin(t - i.y) + cos(1.5*t + i.x));\n c += 1.0/length(vec2(p.x / (cos(i.x+t)/inten),p.y / (cos(i.y+t)/inten)));\n }\n c /= float(5);\n c = 1.17-pow(c, 1.4);\n vec4 tex = texture2D(texture,uv0);\n vec3 colour = vec3(pow(abs(c), 20.0));\n colour = clamp(colour + vec3(0.0, 0.0, .0), 0.0, tex.a);\n float alpha = c*tex[3];\n tex[0] = tex[0] + colour[0]*alpha;\n tex[1] = tex[1] + colour[1]*alpha;\n tex[2] = tex[2] + colour[2]*alpha;\n gl_FragColor = vec4(1,1,1,1) * tex;\n}"
}
}
],
"subMetas": {}
}