From 4d84ee074815f73026d13beb4e2291bda3a9ec7e Mon Sep 17 00:00:00 2001 From: caizhitao Date: Mon, 23 Dec 2019 23:34:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=86=85=E5=8F=91=E5=85=89ef?= =?UTF-8?q?fect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/effects/glow-inner.effect | 77 +++++++++++++++------------ assets/effects/glow-inner.effect.meta | 4 +- 2 files changed, 45 insertions(+), 36 deletions(-) diff --git a/assets/effects/glow-inner.effect b/assets/effects/glow-inner.effect index 2335079..6a4825a 100644 --- a/assets/effects/glow-inner.effect +++ b/assets/effects/glow-inner.effect @@ -14,8 +14,8 @@ CCEffect %{ properties: texture: { value: white } alphaThreshold: { value: 0.5 } - glowColor: { value: [1.0, 1.0, 0.0, 1.0], editor: { type: color } } - glowColorSize: { value: 0.01 } + glowColor: { value: [1.0, 1.0, 0.0, 1.0], editor: { type: color , displayName: "发光颜色" } } + glowColorSize: { value: 0.01, editor: {displayName: "发光宽度(百分比)" } } }% @@ -80,64 +80,73 @@ CCProgram fs %{ * 获取指定角度方向,距离为xxx的像素的透明度 * * @param angle 角度 [0.0, 360.0] - * @param distance 距离 [0.0, 1.0] + * @param dist 距离 [0.0, 1.0] * * @return alpha [0.0, 1.0] */ - float getColorAlpha(float angle, float distance) { + float getColorAlpha(float angle, float dist) { // 角度转弧度,公式为:弧度 = 角度 * (pi / 180) float radian = angle * 0.01745329252; // 这个浮点数是 pi / 180 - vec4 color = texture(texture, v_uv0 + vec2(distance * cos(radian), distance * sin(radian))); + vec4 color = texture(texture, v_uv0 + vec2(dist * cos(radian), dist * sin(radian))); return color.a; } /** * 获取指定距离的周边像素的透明度平均值 * - * @param distance 距离 [0.0, 1.0] + * @param dist 距离 [0.0, 1.0] * * @return average alpha [0.0, 1.0] */ - float getDistanceAverageAlpha(float distance) { + float getAverageAlpha(float dist) { float totalAlpha = 0.0; - totalAlpha += getColorAlpha(0.0, distance); - totalAlpha += getColorAlpha(30.0, distance); - totalAlpha += getColorAlpha(60.0, distance); - totalAlpha += getColorAlpha(90.0, distance); - totalAlpha += getColorAlpha(120.0, distance); - totalAlpha += getColorAlpha(150.0, distance); - totalAlpha += getColorAlpha(180.0, distance); - totalAlpha += getColorAlpha(210.0, distance); - totalAlpha += getColorAlpha(240.0, distance); - totalAlpha += getColorAlpha(270.0, distance); - totalAlpha += getColorAlpha(300.0, distance); - totalAlpha += getColorAlpha(330.0, distance); - return totalAlpha * (1.0 / 12.0); + // 以30度为一个单位,那么「周边」就由0到360度中共计12个点的组成 + totalAlpha += getColorAlpha(0.0, dist); + totalAlpha += getColorAlpha(30.0, dist); + totalAlpha += getColorAlpha(60.0, dist); + totalAlpha += getColorAlpha(90.0, dist); + totalAlpha += getColorAlpha(120.0, dist); + totalAlpha += getColorAlpha(150.0, dist); + totalAlpha += getColorAlpha(180.0, dist); + totalAlpha += getColorAlpha(210.0, dist); + totalAlpha += getColorAlpha(240.0, dist); + totalAlpha += getColorAlpha(270.0, dist); + totalAlpha += getColorAlpha(300.0, dist); + totalAlpha += getColorAlpha(330.0, dist); + // 1 / 12 = 0.08333 + return totalAlpha * 0.0833; } /** * 获取发光的透明度 */ float getGlowAlpha() { - // 原来已经透明的点不处理 + // 如果发光宽度为0 + if (glowColorSize == 0.0) { + return 0.0; + } + + // 原来已经接近透明的点不处理 + // 一般图像边缘会有一些半透明点,这些透明点我们不处理,让它保持原样,否则就是会有内描边效果 vec4 srcColor = texture(texture, v_uv0); - if (srcColor.a < 0.0000000001) { + if (srcColor.a < 0.1) { return srcColor.a; } - // 处理原来不透明的点,求周边平均透明度 + // 将传入的指定距离,平均分成10圈,求出每一圈的平均透明度, + // 然后求和取平均值,那么就可以得到该点的平均透明度 float totalAlpha = 0.0; - totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.1); - totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.2); - totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.3); - totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.4); - totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.5); - totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.6); - totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.7); - totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.8); - totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.9); - totalAlpha += getDistanceAverageAlpha(glowColorSize * 1.0); - return totalAlpha * (1.0 / 10.0); + totalAlpha += getAverageAlpha(glowColorSize * 0.1); + totalAlpha += getAverageAlpha(glowColorSize * 0.2); + totalAlpha += getAverageAlpha(glowColorSize * 0.3); + totalAlpha += getAverageAlpha(glowColorSize * 0.4); + totalAlpha += getAverageAlpha(glowColorSize * 0.5); + totalAlpha += getAverageAlpha(glowColorSize * 0.6); + totalAlpha += getAverageAlpha(glowColorSize * 0.7); + totalAlpha += getAverageAlpha(glowColorSize * 0.8); + totalAlpha += getAverageAlpha(glowColorSize * 0.9); + totalAlpha += getAverageAlpha(glowColorSize * 1.0); + return totalAlpha * 0.1; } #endif diff --git a/assets/effects/glow-inner.effect.meta b/assets/effects/glow-inner.effect.meta index d641606..2e336a7 100644 --- a/assets/effects/glow-inner.effect.meta +++ b/assets/effects/glow-inner.effect.meta @@ -5,11 +5,11 @@ { "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 SHOW_INNER_GLOW\n\nuniform vec4 glowColor;\nuniform float glowColorSize;\n\n/**\n * 获取指定角度方向,距离为xxx的像素的透明度\n *\n * @param angle 角度 [0.0, 360.0]\n * @param distance 距离 [0.0, 1.0]\n *\n * @return alpha [0.0, 1.0]\n */\nfloat getColorAlpha(float angle, float distance) {\n\n float radian = angle * 0.01745329252;\n\n vec4 color = texture2D(texture, v_uv0 + vec2(distance * cos(radian), distance * sin(radian))); \n return color.a;\n}\n\n/**\n * 获取指定距离的周边像素的透明度平均值\n *\n * @param distance 距离 [0.0, 1.0]\n *\n * @return average alpha [0.0, 1.0]\n */\nfloat getDistanceAverageAlpha(float distance) {\n float totalAlpha = 0.0;\n totalAlpha += getColorAlpha(0.0, distance);\n totalAlpha += getColorAlpha(30.0, distance);\n totalAlpha += getColorAlpha(60.0, distance);\n totalAlpha += getColorAlpha(90.0, distance);\n totalAlpha += getColorAlpha(120.0, distance);\n totalAlpha += getColorAlpha(150.0, distance);\n totalAlpha += getColorAlpha(180.0, distance);\n totalAlpha += getColorAlpha(210.0, distance);\n totalAlpha += getColorAlpha(240.0, distance);\n totalAlpha += getColorAlpha(270.0, distance);\n totalAlpha += getColorAlpha(300.0, distance);\n totalAlpha += getColorAlpha(330.0, distance);\n return totalAlpha * (1.0 / 12.0);\n}\n\n/**\n * 获取发光的透明度\n */\nfloat getGlowAlpha() {\n\n vec4 srcColor = texture2D(texture, v_uv0);\n if (srcColor.a < 0.0000000001) {\n return srcColor.a;\n }\n\n float totalAlpha = 0.0;\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.1);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.2);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.3);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.4);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.5);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.6);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.7);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.8);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.9);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 1.0);\n return totalAlpha * (1.0 / 10.0);\n}\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 SHOW_INNER_GLOW\n\n vec4 color_dest = o;\n\n float alpha = getGlowAlpha();\n\n if (alpha > 0.1) {\n alpha = 1.0 - alpha;\n\n alpha = -1.0 * (alpha - 1.0) * (alpha - 1.0) * (alpha - 1.0) * (alpha - 1.0) + 1.0;\n }\n vec4 color_src = glowColor * alpha;\n\n gl_FragColor = color_src * color_src.a + color_dest;\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 SHOW_INNER_GLOW\n\nuniform vec4 glowColor;\nuniform float glowColorSize;\n\n/**\n * 获取指定角度方向,距离为xxx的像素的透明度\n *\n * @param angle 角度 [0.0, 360.0]\n * @param dist 距离 [0.0, 1.0]\n *\n * @return alpha [0.0, 1.0]\n */\nfloat getColorAlpha(float angle, float dist) {\n\n float radian = angle * 0.01745329252;\n\n vec4 color = texture2D(texture, v_uv0 + vec2(dist * cos(radian), dist * sin(radian))); \n return color.a;\n}\n\n/**\n * 获取指定距离的周边像素的透明度平均值\n *\n * @param dist 距离 [0.0, 1.0]\n *\n * @return average alpha [0.0, 1.0]\n */\nfloat getAverageAlpha(float dist) {\n float totalAlpha = 0.0;\n\n totalAlpha += getColorAlpha(0.0, dist);\n totalAlpha += getColorAlpha(30.0, dist);\n totalAlpha += getColorAlpha(60.0, dist);\n totalAlpha += getColorAlpha(90.0, dist);\n totalAlpha += getColorAlpha(120.0, dist);\n totalAlpha += getColorAlpha(150.0, dist);\n totalAlpha += getColorAlpha(180.0, dist);\n totalAlpha += getColorAlpha(210.0, dist);\n totalAlpha += getColorAlpha(240.0, dist);\n totalAlpha += getColorAlpha(270.0, dist);\n totalAlpha += getColorAlpha(300.0, dist);\n totalAlpha += getColorAlpha(330.0, dist);\n\n return totalAlpha * 0.0833; \n}\n\n/**\n * 获取发光的透明度\n */\nfloat getGlowAlpha() {\n\n if (glowColorSize == 0.0) {\n return 0.0;\n }\n\n vec4 srcColor = texture2D(texture, v_uv0);\n if (srcColor.a < 0.1) {\n return srcColor.a;\n }\n\n float totalAlpha = 0.0;\n totalAlpha += getAverageAlpha(glowColorSize * 0.1);\n totalAlpha += getAverageAlpha(glowColorSize * 0.2);\n totalAlpha += getAverageAlpha(glowColorSize * 0.3);\n totalAlpha += getAverageAlpha(glowColorSize * 0.4);\n totalAlpha += getAverageAlpha(glowColorSize * 0.5);\n totalAlpha += getAverageAlpha(glowColorSize * 0.6);\n totalAlpha += getAverageAlpha(glowColorSize * 0.7);\n totalAlpha += getAverageAlpha(glowColorSize * 0.8);\n totalAlpha += getAverageAlpha(glowColorSize * 0.9);\n totalAlpha += getAverageAlpha(glowColorSize * 1.0);\n return totalAlpha * 0.1;\n}\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 SHOW_INNER_GLOW\n\n vec4 color_dest = o;\n\n float alpha = getGlowAlpha();\n\n if (alpha > 0.1) {\n alpha = 1.0 - alpha;\n\n alpha = -1.0 * (alpha - 1.0) * (alpha - 1.0) * (alpha - 1.0) * (alpha - 1.0) + 1.0;\n }\n vec4 color_src = glowColor * alpha;\n\n gl_FragColor = color_src * color_src.a + color_dest;\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 SHOW_INNER_GLOW\n\nuniform glow {\n\n vec4 glowColor;\n\n float glowColorSize;\n\n};\n\n/**\n * 获取指定角度方向,距离为xxx的像素的透明度\n *\n * @param angle 角度 [0.0, 360.0]\n * @param distance 距离 [0.0, 1.0]\n *\n * @return alpha [0.0, 1.0]\n */\nfloat getColorAlpha(float angle, float distance) {\n\n float radian = angle * 0.01745329252;\n\n vec4 color = texture(texture, v_uv0 + vec2(distance * cos(radian), distance * sin(radian))); \n return color.a;\n}\n\n/**\n * 获取指定距离的周边像素的透明度平均值\n *\n * @param distance 距离 [0.0, 1.0]\n *\n * @return average alpha [0.0, 1.0]\n */\nfloat getDistanceAverageAlpha(float distance) {\n float totalAlpha = 0.0;\n totalAlpha += getColorAlpha(0.0, distance);\n totalAlpha += getColorAlpha(30.0, distance);\n totalAlpha += getColorAlpha(60.0, distance);\n totalAlpha += getColorAlpha(90.0, distance);\n totalAlpha += getColorAlpha(120.0, distance);\n totalAlpha += getColorAlpha(150.0, distance);\n totalAlpha += getColorAlpha(180.0, distance);\n totalAlpha += getColorAlpha(210.0, distance);\n totalAlpha += getColorAlpha(240.0, distance);\n totalAlpha += getColorAlpha(270.0, distance);\n totalAlpha += getColorAlpha(300.0, distance);\n totalAlpha += getColorAlpha(330.0, distance);\n return totalAlpha * (1.0 / 12.0);\n}\n\n/**\n * 获取发光的透明度\n */\nfloat getGlowAlpha() {\n\n vec4 srcColor = texture(texture, v_uv0);\n if (srcColor.a < 0.0000000001) {\n return srcColor.a;\n }\n\n float totalAlpha = 0.0;\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.1);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.2);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.3);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.4);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.5);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.6);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.7);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.8);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 0.9);\n totalAlpha += getDistanceAverageAlpha(glowColorSize * 1.0);\n return totalAlpha * (1.0 / 10.0);\n}\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 SHOW_INNER_GLOW\n\n vec4 color_dest = o;\n\n float alpha = getGlowAlpha();\n\n if (alpha > 0.1) {\n alpha = 1.0 - alpha;\n\n alpha = -1.0 * (alpha - 1.0) * (alpha - 1.0) * (alpha - 1.0) * (alpha - 1.0) + 1.0;\n }\n vec4 color_src = glowColor * alpha;\n\n gl_FragColor = color_src * color_src.a + color_dest;\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 SHOW_INNER_GLOW\n\nuniform glow {\n\n vec4 glowColor;\n\n float glowColorSize;\n\n};\n\n/**\n * 获取指定角度方向,距离为xxx的像素的透明度\n *\n * @param angle 角度 [0.0, 360.0]\n * @param dist 距离 [0.0, 1.0]\n *\n * @return alpha [0.0, 1.0]\n */\nfloat getColorAlpha(float angle, float dist) {\n\n float radian = angle * 0.01745329252;\n\n vec4 color = texture(texture, v_uv0 + vec2(dist * cos(radian), dist * sin(radian))); \n return color.a;\n}\n\n/**\n * 获取指定距离的周边像素的透明度平均值\n *\n * @param dist 距离 [0.0, 1.0]\n *\n * @return average alpha [0.0, 1.0]\n */\nfloat getAverageAlpha(float dist) {\n float totalAlpha = 0.0;\n\n totalAlpha += getColorAlpha(0.0, dist);\n totalAlpha += getColorAlpha(30.0, dist);\n totalAlpha += getColorAlpha(60.0, dist);\n totalAlpha += getColorAlpha(90.0, dist);\n totalAlpha += getColorAlpha(120.0, dist);\n totalAlpha += getColorAlpha(150.0, dist);\n totalAlpha += getColorAlpha(180.0, dist);\n totalAlpha += getColorAlpha(210.0, dist);\n totalAlpha += getColorAlpha(240.0, dist);\n totalAlpha += getColorAlpha(270.0, dist);\n totalAlpha += getColorAlpha(300.0, dist);\n totalAlpha += getColorAlpha(330.0, dist);\n\n return totalAlpha * 0.0833; \n}\n\n/**\n * 获取发光的透明度\n */\nfloat getGlowAlpha() {\n\n if (glowColorSize == 0.0) {\n return 0.0;\n }\n\n vec4 srcColor = texture(texture, v_uv0);\n if (srcColor.a < 0.1) {\n return srcColor.a;\n }\n\n float totalAlpha = 0.0;\n totalAlpha += getAverageAlpha(glowColorSize * 0.1);\n totalAlpha += getAverageAlpha(glowColorSize * 0.2);\n totalAlpha += getAverageAlpha(glowColorSize * 0.3);\n totalAlpha += getAverageAlpha(glowColorSize * 0.4);\n totalAlpha += getAverageAlpha(glowColorSize * 0.5);\n totalAlpha += getAverageAlpha(glowColorSize * 0.6);\n totalAlpha += getAverageAlpha(glowColorSize * 0.7);\n totalAlpha += getAverageAlpha(glowColorSize * 0.8);\n totalAlpha += getAverageAlpha(glowColorSize * 0.9);\n totalAlpha += getAverageAlpha(glowColorSize * 1.0);\n return totalAlpha * 0.1;\n}\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 SHOW_INNER_GLOW\n\n vec4 color_dest = o;\n\n float alpha = getGlowAlpha();\n\n if (alpha > 0.1) {\n alpha = 1.0 - alpha;\n\n alpha = -1.0 * (alpha - 1.0) * (alpha - 1.0) * (alpha - 1.0) * (alpha - 1.0) + 1.0;\n }\n vec4 color_src = glowColor * alpha;\n\n gl_FragColor = color_src * color_src.a + color_dest;\n #endif\n}\n" } } ],