This commit is contained in:
caizhitao 2020-02-17 10:23:27 +08:00
parent 6ea6375fdb
commit 04959cdc13
23 changed files with 62 additions and 40 deletions

View File

@ -1,5 +1,5 @@
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
// 描边特效
CCEffect %{
techniques:
- passes:
@ -31,6 +31,7 @@ CCEffect %{
range: [0.0, 1.0]
}
}
}%
@ -109,7 +110,6 @@ CCProgram fs %{
}
#endif
void main () {
vec4 o = vec4(1, 1, 1, 1);

View File

@ -1,6 +1,6 @@
{
"ver": "1.0.25",
"uuid": "559dcd1e-233b-4e1f-b1da-733c9232f06f",
"uuid": "34c2ed47-4d59-41c4-b91c-157c32e9d0eb",
"compiledShaders": [
{
"glsl1": {

View File

@ -43,6 +43,22 @@ CCEffect %{
tooltip: "扩散半径"
}
}
# 裁剪掉透明区域上的光
cropAlpha: {
value: 1.0,
editor: {
tooltip: "是否裁剪透明区域上的光。0不启用非0启用"
}
}
# 是否启用迷雾效果
enableFog: {
value: 0.0,
editor: {
tooltip: "是否启用迷雾效果。0不启用非0启用"
}
}
}%
@ -104,13 +120,13 @@ CCProgram fs %{
// 扩展半径
float radius;
// 裁剪掉透明区域上的
// ps编辑器还不支持 bool 类型的样子,因此没在 CCEffect 中定义
bool cropAlpha;
// 裁剪掉透明区域上的光
// ps编辑器还不支持 bool 类型的样子,因此用float来定义
float cropAlpha;
// 是否启用迷雾效果
// ps编辑器还不支持 bool 类型的样子,因此没在 CCEffect 中定义
bool enableFog;
// ps编辑器还不支持 bool 类型的样子,因此用float来定义
float enableFog;
};
/**
@ -123,12 +139,12 @@ CCProgram fs %{
float a = 1.0 ;
// 裁剪掉透明区域上的点光
if (cropAlpha) {
if (bool(cropAlpha)) {
a *= step(0.01, textureColor.a);
}
// 裁剪掉范围外的uv迷雾效果
if (!enableFog) {
// 裁剪掉光束范围外的uv迷雾效果
if (!bool(enableFog)) {
a *= step(dis, radius);
}

View File

@ -5,11 +5,11 @@
{
"glsl1": {
"vert": "\nprecision highp float;\nuniform mediump mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}",
"frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n#if ENABLE_DIFFUSION\nuniform vec4 centerColor;\nuniform vec2 centerPoint;\nuniform float radius;\nuniform bool cropAlpha;\nuniform bool enableFog;\nvec4 addLightColor(vec4 textureColor, vec2 centerPoint, float radius, vec4 centerColor) {\n float dis = distance(v_uv0, centerPoint);\n float a = 1.0 ;\n if (cropAlpha) {\n a *= step(0.01, textureColor.a);\n }\n if (!enableFog) {\n a *= step(dis, radius);\n }\n a *= 1.0 - (dis / radius);\n vec4 lightColor = centerColor * a;\n return textureColor * textureColor.a + lightColor;\n}\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\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 o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n #if ENABLE_DIFFUSION\n gl_FragColor = addLightColor(gl_FragColor, centerPoint, radius, centerColor);\n #endif\n}"
"frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n#if ENABLE_DIFFUSION\nuniform vec4 centerColor;\nuniform vec2 centerPoint;\nuniform float radius;\nuniform float cropAlpha;\nuniform float enableFog;\nvec4 addLightColor(vec4 textureColor, vec2 centerPoint, float radius, vec4 centerColor) {\n float dis = distance(v_uv0, centerPoint);\n float a = 1.0 ;\n if (bool(cropAlpha)) {\n a *= step(0.01, textureColor.a);\n }\n if (!bool(enableFog)) {\n a *= step(dis, radius);\n }\n a *= 1.0 - (dis / radius);\n vec4 lightColor = centerColor * a;\n return textureColor * textureColor.a + lightColor;\n}\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\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 o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n #if ENABLE_DIFFUSION\n gl_FragColor = addLightColor(gl_FragColor, centerPoint, radius, centerColor);\n #endif\n}"
},
"glsl3": {
"vert": "\nprecision highp float;\nuniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_nativeSize;\n highp mat4 cc_matView;\n mediump mat4 cc_matViewInv;\n mediump mat4 cc_matProj;\n mediump mat4 cc_matProjInv;\n mediump mat4 cc_matViewProj;\n mediump mat4 cc_matViewProjInv;\n mediump vec4 cc_cameraPos;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}",
"frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n#if ENABLE_DIFFUSION\nuniform Diffusion {\n vec4 centerColor;\n vec2 centerPoint;\n float radius;\n bool cropAlpha;\n bool enableFog;\n};\nvec4 addLightColor(vec4 textureColor, vec2 centerPoint, float radius, vec4 centerColor) {\n float dis = distance(v_uv0, centerPoint);\n float a = 1.0 ;\n if (cropAlpha) {\n a *= step(0.01, textureColor.a);\n }\n if (!enableFog) {\n a *= step(dis, radius);\n }\n a *= 1.0 - (dis / radius);\n vec4 lightColor = centerColor * a;\n return textureColor * textureColor.a + lightColor;\n}\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\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 o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n #if ENABLE_DIFFUSION\n gl_FragColor = addLightColor(gl_FragColor, centerPoint, radius, centerColor);\n #endif\n}"
"frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\n#if ENABLE_DIFFUSION\nuniform Diffusion {\n vec4 centerColor;\n vec2 centerPoint;\n float radius;\n float cropAlpha;\n float enableFog;\n};\nvec4 addLightColor(vec4 textureColor, vec2 centerPoint, float radius, vec4 centerColor) {\n float dis = distance(v_uv0, centerPoint);\n float a = 1.0 ;\n if (bool(cropAlpha)) {\n a *= step(0.01, textureColor.a);\n }\n if (!bool(enableFog)) {\n a *= step(dis, radius);\n }\n a *= 1.0 - (dis / radius);\n vec4 lightColor = centerColor * a;\n return textureColor * textureColor.a + lightColor;\n}\n#endif\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\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 o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n #if ENABLE_DIFFUSION\n gl_FragColor = addLightColor(gl_FragColor, centerPoint, radius, centerColor);\n #endif\n}"
}
}
],

View File

@ -6,6 +6,7 @@
"_effectAsset": {
"__uuid__": "e9682cd1-a19c-4fcb-ad8c-cf1783b805e6"
},
"_techniqueIndex": 0,
"_techniqueData": {
"0": {
"props": {

View File

@ -6,6 +6,7 @@
"_effectAsset": {
"__uuid__": "41f4d474-d707-45bb-af93-637573f92d54"
},
"_techniqueIndex": 0,
"_techniqueData": {
"0": {
"defines": {

View File

@ -6,6 +6,7 @@
"_effectAsset": {
"__uuid__": "2e5b29d9-dd5e-4f3d-92e9-e580745b3bc8"
},
"_techniqueIndex": 0,
"_techniqueData": {
"0": {
"defines": {

View File

@ -6,6 +6,7 @@
"_effectAsset": {
"__uuid__": "9638979d-62b3-4e5b-adea-7ad706e66e65"
},
"_techniqueIndex": 0,
"_techniqueData": {
"0": {
"props": {

View File

@ -6,6 +6,7 @@
"_effectAsset": {
"__uuid__": "211eddf3-c53d-46e3-8c09-c1bf38e644e2"
},
"_techniqueIndex": 0,
"_techniqueData": {
"0": {
"defines": {

View File

@ -1,27 +1,16 @@
{
"__type__": "cc.Material",
"_name": "sprite-outline",
"_name": "New Material",
"_objFlags": 0,
"_native": "",
"_effectAsset": {
"__uuid__": "559dcd1e-233b-4e1f-b1da-733c9232f06f"
"__uuid__": "34c2ed47-4d59-41c4-b91c-157c32e9d0eb"
},
"_techniqueIndex": 0,
"_techniqueData": {
"0": {
"props": {
"texture": null,
"outlineColor": {
"__type__": "cc.Color",
"r": 255,
"g": 0,
"b": 0,
"a": 255
},
"outlineWidth": 0.002
},
"defines": {
"USE_TEXTURE": true,
"USE_ALPHA_TEST": false,
"SHOW_OUT_LINE": true
}
}

View File

@ -1,6 +1,6 @@
{
"ver": "1.0.3",
"uuid": "daf44951-2c80-4778-b99f-52cfc78ab053",
"uuid": "df1eb418-ec89-4e04-a579-03fcfbc315fc",
"dataAsSubAsset": null,
"subMetas": {}
}

View File

@ -6,6 +6,7 @@
"_effectAsset": {
"__uuid__": "72a182fc-08a6-4faa-8e36-8bd84b4a0b53"
},
"_techniqueIndex": 0,
"_techniqueData": {
"0": {
"props": {

View File

@ -6,6 +6,7 @@
"_effectAsset": {
"__uuid__": "a4afedba-5234-44d7-9031-cba83051d521"
},
"_techniqueIndex": 0,
"_techniqueData": {
"0": {
"defines": {

View File

@ -6,6 +6,7 @@
"_effectAsset": {
"__uuid__": "7c24b57e-e819-4fc9-a8d2-b06cf61b782d"
},
"_techniqueIndex": 0,
"_techniqueData": {
"0": {
"defines": {

View File

@ -174,7 +174,7 @@
"array": [
0,
0,
492.17758360225525,
324.7595264191645,
0,
0,
0,
@ -658,6 +658,8 @@
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 2,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
@ -1225,6 +1227,8 @@
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 0,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
@ -1367,7 +1371,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 384,
"height": 583.73
"height": 590.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@ -1475,7 +1479,7 @@
"_enabled": true,
"_materials": [
{
"__uuid__": "daf44951-2c80-4778-b99f-52cfc78ab053"
"__uuid__": "df1eb418-ec89-4e04-a579-03fcfbc315fc"
}
],
"_srcBlendFactor": 770,
@ -1569,7 +1573,7 @@
"_enabled": true,
"_materials": [
{
"__uuid__": "daf44951-2c80-4778-b99f-52cfc78ab053"
"__uuid__": "df1eb418-ec89-4e04-a579-03fcfbc315fc"
}
],
"_srcBlendFactor": 770,
@ -1663,7 +1667,7 @@
"_enabled": true,
"_materials": [
{
"__uuid__": "daf44951-2c80-4778-b99f-52cfc78ab053"
"__uuid__": "df1eb418-ec89-4e04-a579-03fcfbc315fc"
}
],
"_srcBlendFactor": 770,
@ -1757,7 +1761,7 @@
"_enabled": true,
"_materials": [
{
"__uuid__": "daf44951-2c80-4778-b99f-52cfc78ab053"
"__uuid__": "df1eb418-ec89-4e04-a579-03fcfbc315fc"
}
],
"_srcBlendFactor": 770,
@ -1851,7 +1855,7 @@
"_enabled": true,
"_materials": [
{
"__uuid__": "daf44951-2c80-4778-b99f-52cfc78ab053"
"__uuid__": "df1eb418-ec89-4e04-a579-03fcfbc315fc"
}
],
"_useOriginalSize": false,
@ -1864,6 +1868,8 @@
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
@ -1897,7 +1903,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 167.5,
"height": 33.33
"height": 40
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@ -1909,7 +1915,7 @@
"ctor": "Float64Array",
"array": [
0,
-567.065,
-570.4000000000001,
0,
0,
0,
@ -1943,7 +1949,7 @@
"_enabled": true,
"_materials": [
{
"__uuid__": "daf44951-2c80-4778-b99f-52cfc78ab053"
"__uuid__": "df1eb418-ec89-4e04-a579-03fcfbc315fc"
}
],
"_useOriginalSize": false,
@ -1958,6 +1964,8 @@
"_isSystemFontUsed": false,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
@ -2003,7 +2011,7 @@
"_layoutSize": {
"__type__": "cc.Size",
"width": 384,
"height": 583.73
"height": 590.4
},
"_resize": 1,
"_N$layoutType": 2,
@ -2086,6 +2094,7 @@
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0
"_originalHeight": 0,
"_id": "f7GTkBg4hJMpPgwjS3Vbiz"
}
]