diff --git a/assets/effects/sprite-gaussian-blur.effect b/assets/effects/sprite-gaussian-blur-v1.effect similarity index 73% rename from assets/effects/sprite-gaussian-blur.effect rename to assets/effects/sprite-gaussian-blur-v1.effect index 4df48c1..6df0cc9 100644 --- a/assets/effects/sprite-gaussian-blur.effect +++ b/assets/effects/sprite-gaussian-blur-v1.effect @@ -1,5 +1,10 @@ // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. // 高斯模糊 +// +// 参考资料(必读) +// * http://www.ruanyifeng.com/blog/2012/11/gaussian_blur.html +// * https://zh.wikipedia.org/wiki/%E9%AB%98%E6%96%AF%E6%A8%A1%E7%B3%8A + CCEffect %{ techniques: @@ -84,9 +89,9 @@ CCProgram fs %{ // 定义无理数 #define e 2.718281828459045 - // 定义标准方差值 - #define stDev 0.84089642 - // #define stDev 1.5 + // 定义标准方差值(方差值越大,越模糊,但是需要计算的高斯矩阵范围会变大,从而带来巨大的计算量) + // #define stDev 0.84089642 + #define stDev 1.5 // #define stDev 5.0 // #define stDev 10.0 @@ -103,19 +108,12 @@ CCProgram fs %{ } /** - * 获取权重(对应二维高斯函数公式) + * 获取权重(对应二维高斯函数公式,见 https://zh.wikipedia.org/wiki/%E9%AB%98%E6%96%AF%E6%A8%A1%E7%B3%8A ) */ float getWeight(float x, float y) { return (1.0 / (2.0 * pi * pow(stDev, 2.0))) * pow(1.0 / e, (pow(x, 2.0) + pow(y, 2.0)) / (2.0 * pow(stDev, 2.0))); } - /** - * 获取权重的加权平均值 - */ - float getAverageWeight(float x, float y, float totalWeight) { - return getWeight(x, y) / totalWeight; - } - #endif void main () { @@ -135,6 +133,7 @@ CCProgram fs %{ gl_FragColor = o; #if ENABLE_GAUSSIAN_BLUR + // 根据高斯分布(也叫正态分布),在3个标准差范围内的分布比例占到99%的权重,因此我们只需要计算矩阵范围 [6 * stDev + 1, 6 * stDev +1] 上的权重 const float size = floor(stDev * 6.0 + 1.0); const float halfSize = floor(size / 2.0); @@ -148,7 +147,7 @@ CCProgram fs %{ // } // } - // v2:因为分布是对称的,所以只计算原点、X轴正方向、Y轴正方向、第一象限的权重即可,相比起v1版本,减少很多循环计算 + // v2:因为高斯分布是对称的,所以只计算原点、X轴正方向 * 2 、Y轴正方向 * 2 、第一象限的权重 * 4即可求出所有权重之和,相比起v1版本,减少很多循环计算 // 原点 float totalWeight = getWeight(0.0, 0.0); @@ -168,15 +167,23 @@ CCProgram fs %{ } } - // 步骤二:加权平均值 + // TODO: + // + // 因为权重矩阵是一次性计算即可不断应用,因此可以将权重矩阵的计算放到CPU计算,并传入到Shader直接渲染,因此有以下优化方案 + // + // v3:原始权重矩阵在CPU计算并传入到Shader + // v4:加权平均后的权重矩阵在CPU计算并传入Shader + + + // 步骤二:采样周边像素并应用加权平均值,得出最终像素值 vec4 finalColor = vec4(0.0, 0.0, 0.0, 0.0); - float divider = 0.01; + // float divider = 0.01; float onePxWidth = 1.0 / textureSize.x; float onePxHeight = 1.0 / textureSize.y; for(float x = -halfSize; x<= halfSize; x++) { for (float y = -halfSize; y<= halfSize; y++) { // 求出对应坐标的真正权重(对应权重矩阵) - float weight = getAverageWeight(x, y, totalWeight); + float weight = getWeight(x, y) / totalWeight; // 求出对应坐标像素颜色值的加权值 // finalColor += texture(texture, v_uv0 + vec2(divider * x, divider * y)) * weight; diff --git a/assets/effects/sprite-gaussian-blur-v1.effect.meta b/assets/effects/sprite-gaussian-blur-v1.effect.meta new file mode 100644 index 0000000..fd00a2d --- /dev/null +++ b/assets/effects/sprite-gaussian-blur-v1.effect.meta @@ -0,0 +1,17 @@ +{ + "ver": "1.0.23", + "uuid": "41f4d474-d707-45bb-af93-637573f92d54", + "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_GAUSSIAN_BLUR\n\nuniform vec2 textureSize;\n/**\n * 获取权重(对应二维高斯函数公式,见 https:\n\n */\nfloat getWeight(float x, float y) {\n return (1.0 / (2.0 * 3.141592653589793 * pow(1.5, 2.0))) * pow(1.0 / 2.718281828459045, (pow(x, 2.0) + pow(y, 2.0)) / (2.0 * pow(1.5, 2.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 #if ENABLE_GAUSSIAN_BLUR\n\n const float size = floor(1.5 * 6.0 + 1.0);\n const float halfSize = floor(size / 2.0);\n\n float totalWeight = getWeight(0.0, 0.0);\n\n for(float x = 1.0; x <= halfSize; x++) {\n totalWeight += getWeight(x, 0.0) * 2.0;\n }\n\n for(float y = 1.0; y <= halfSize; y++) {\n totalWeight += getWeight(0.0, y) * 2.0;\n }\n\n for(float x = 1.0; x <= halfSize; x++) {\n for (float y = 1.0; y<= halfSize; y++) {\n totalWeight += getWeight(x, y) * 4.0;\n }\n }\n\n vec4 finalColor = vec4(0.0, 0.0, 0.0, 0.0);\n\n float onePxWidth = 1.0 / textureSize.x;\n float onePxHeight = 1.0 / textureSize.y;\n for(float x = -halfSize; x<= halfSize; x++) {\n for (float y = -halfSize; y<= halfSize; y++) {\n\n float weight = getWeight(x, y) / totalWeight;\n\n finalColor += texture2D(texture, v_uv0 + vec2(onePxWidth * x, onePxHeight * y)) * weight;\n }\n }\n gl_FragColor = finalColor;\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_GAUSSIAN_BLUR\n\nuniform GaussianBlur {\n\n vec2 textureSize;\n\n}\n\n/**\n * 获取权重(对应二维高斯函数公式,见 https:\n\n */\nfloat getWeight(float x, float y) {\n return (1.0 / (2.0 * 3.141592653589793 * pow(1.5, 2.0))) * pow(1.0 / 2.718281828459045, (pow(x, 2.0) + pow(y, 2.0)) / (2.0 * pow(1.5, 2.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 #if ENABLE_GAUSSIAN_BLUR\n\n const float size = floor(1.5 * 6.0 + 1.0);\n const float halfSize = floor(size / 2.0);\n\n float totalWeight = getWeight(0.0, 0.0);\n\n for(float x = 1.0; x <= halfSize; x++) {\n totalWeight += getWeight(x, 0.0) * 2.0;\n }\n\n for(float y = 1.0; y <= halfSize; y++) {\n totalWeight += getWeight(0.0, y) * 2.0;\n }\n\n for(float x = 1.0; x <= halfSize; x++) {\n for (float y = 1.0; y<= halfSize; y++) {\n totalWeight += getWeight(x, y) * 4.0;\n }\n }\n\n vec4 finalColor = vec4(0.0, 0.0, 0.0, 0.0);\n\n float onePxWidth = 1.0 / textureSize.x;\n float onePxHeight = 1.0 / textureSize.y;\n for(float x = -halfSize; x<= halfSize; x++) {\n for (float y = -halfSize; y<= halfSize; y++) {\n\n float weight = getWeight(x, y) / totalWeight;\n\n finalColor += texture(texture, v_uv0 + vec2(onePxWidth * x, onePxHeight * y)) * weight;\n }\n }\n gl_FragColor = finalColor;\n #endif\n}\n" + } + } + ], + "subMetas": {} +} \ No newline at end of file diff --git a/assets/effects/sprite-gaussian-blur.effect.meta b/assets/effects/sprite-gaussian-blur.effect.meta deleted file mode 100644 index 7539272..0000000 --- a/assets/effects/sprite-gaussian-blur.effect.meta +++ /dev/null @@ -1,17 +0,0 @@ -{ - "ver": "1.0.23", - "uuid": "41f4d474-d707-45bb-af93-637573f92d54", - "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_GAUSSIAN_BLUR\n\nuniform vec2 textureSize;\n/**\n * 获取权重(对应二维高斯函数公式)\n */\nfloat getWeight(float x, float y) {\n return (1.0 / (2.0 * 3.141592653589793 * pow(0.84089642, 2.0))) * pow(1.0 / 2.718281828459045, (pow(x, 2.0) + pow(y, 2.0)) / (2.0 * pow(0.84089642, 2.0)));\n}\n\n/**\n * 获取权重的加权平均值\n */\nfloat getAverageWeight(float x, float y, float totalWeight) {\n return getWeight(x, y) / totalWeight;\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 #if ENABLE_GAUSSIAN_BLUR\n\n const float size = floor(0.84089642 * 6.0 + 1.0);\n const float halfSize = floor(size / 2.0);\n\n float totalWeight = getWeight(0.0, 0.0);\n\n for(float x = 1.0; x <= halfSize; x++) {\n totalWeight += getWeight(x, 0.0) * 2.0;\n }\n\n for(float y = 1.0; y <= halfSize; y++) {\n totalWeight += getWeight(0.0, y) * 2.0;\n }\n\n for(float x = 1.0; x <= halfSize; x++) {\n for (float y = 1.0; y<= halfSize; y++) {\n totalWeight += getWeight(x, y) * 4.0;\n }\n }\n\n vec4 finalColor = vec4(0.0, 0.0, 0.0, 0.0);\n float divider = 0.01; \n float onePxWidth = 1.0 / textureSize.x;\n float onePxHeight = 1.0 / textureSize.y;\n for(float x = -halfSize; x<= halfSize; x++) {\n for (float y = -halfSize; y<= halfSize; y++) {\n\n float weight = getAverageWeight(x, y, totalWeight);\n\n finalColor += texture2D(texture, v_uv0 + vec2(onePxWidth * x, onePxHeight * y)) * weight;\n }\n }\n gl_FragColor = finalColor;\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_GAUSSIAN_BLUR\n\nuniform GaussianBlur {\n\n vec2 textureSize;\n\n}\n\n/**\n * 获取权重(对应二维高斯函数公式)\n */\nfloat getWeight(float x, float y) {\n return (1.0 / (2.0 * 3.141592653589793 * pow(0.84089642, 2.0))) * pow(1.0 / 2.718281828459045, (pow(x, 2.0) + pow(y, 2.0)) / (2.0 * pow(0.84089642, 2.0)));\n}\n\n/**\n * 获取权重的加权平均值\n */\nfloat getAverageWeight(float x, float y, float totalWeight) {\n return getWeight(x, y) / totalWeight;\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 #if ENABLE_GAUSSIAN_BLUR\n\n const float size = floor(0.84089642 * 6.0 + 1.0);\n const float halfSize = floor(size / 2.0);\n\n float totalWeight = getWeight(0.0, 0.0);\n\n for(float x = 1.0; x <= halfSize; x++) {\n totalWeight += getWeight(x, 0.0) * 2.0;\n }\n\n for(float y = 1.0; y <= halfSize; y++) {\n totalWeight += getWeight(0.0, y) * 2.0;\n }\n\n for(float x = 1.0; x <= halfSize; x++) {\n for (float y = 1.0; y<= halfSize; y++) {\n totalWeight += getWeight(x, y) * 4.0;\n }\n }\n\n vec4 finalColor = vec4(0.0, 0.0, 0.0, 0.0);\n float divider = 0.01; \n float onePxWidth = 1.0 / textureSize.x;\n float onePxHeight = 1.0 / textureSize.y;\n for(float x = -halfSize; x<= halfSize; x++) {\n for (float y = -halfSize; y<= halfSize; y++) {\n\n float weight = getAverageWeight(x, y, totalWeight);\n\n finalColor += texture(texture, v_uv0 + vec2(onePxWidth * x, onePxHeight * y)) * weight;\n }\n }\n gl_FragColor = finalColor;\n #endif\n}\n" - } - } - ], - "subMetas": {} -} \ No newline at end of file diff --git a/assets/materials/sprite-gaussian-blur.mtl b/assets/materials/sprite-gaussian-blur-v1.mtl similarity index 100% rename from assets/materials/sprite-gaussian-blur.mtl rename to assets/materials/sprite-gaussian-blur-v1.mtl diff --git a/assets/materials/sprite-gaussian-blur.mtl.meta b/assets/materials/sprite-gaussian-blur-v1.mtl.meta similarity index 100% rename from assets/materials/sprite-gaussian-blur.mtl.meta rename to assets/materials/sprite-gaussian-blur-v1.mtl.meta diff --git a/assets/scenes/GaussianBlurEffectScene.fire b/assets/scenes/GaussianBlurV1EffectScene.fire similarity index 99% rename from assets/scenes/GaussianBlurEffectScene.fire rename to assets/scenes/GaussianBlurV1EffectScene.fire index 905dfa3..b71595d 100755 --- a/assets/scenes/GaussianBlurEffectScene.fire +++ b/assets/scenes/GaussianBlurV1EffectScene.fire @@ -171,7 +171,7 @@ "array": [ 0, 0, - 351.60631393648214, + 491.9024293495612, 0, 0, 0, @@ -459,7 +459,7 @@ "_contentSize": { "__type__": "cc.Size", "width": 576, - "height": 60 + "height": -36 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -497,7 +497,7 @@ }, { "__type__": "cc.Node", - "_name": "GrayLevelSlider", + "_name": "BlurSlider", "_objFlags": 0, "_parent": { "__id__": 9 @@ -513,7 +513,7 @@ "__id__": 23 } ], - "_active": true, + "_active": false, "_components": [ { "__id__": 26 @@ -646,8 +646,8 @@ } ], "_useOriginalSize": false, - "_string": "灰化程度:", - "_N$string": "灰化程度:", + "_string": "模糊程度:", + "_N$string": "模糊程度:", "_fontSize": 40, "_lineHeight": 40, "_enableWrapText": true, @@ -1294,7 +1294,7 @@ "_layoutSize": { "__type__": "cc.Size", "width": 576, - "height": 60 + "height": -36 }, "_resize": 1, "_N$layoutType": 2, diff --git a/assets/scenes/GaussianBlurEffectScene.fire.meta b/assets/scenes/GaussianBlurV1EffectScene.fire.meta similarity index 100% rename from assets/scenes/GaussianBlurEffectScene.fire.meta rename to assets/scenes/GaussianBlurV1EffectScene.fire.meta diff --git a/assets/scripts/GaussianBlurEffectScene.ts b/assets/scripts/GaussianBlurV1EffectScene.ts similarity index 62% rename from assets/scripts/GaussianBlurEffectScene.ts rename to assets/scripts/GaussianBlurV1EffectScene.ts index 8c7575e..91449b1 100644 --- a/assets/scripts/GaussianBlurEffectScene.ts +++ b/assets/scripts/GaussianBlurV1EffectScene.ts @@ -1,27 +1,27 @@ const { ccclass, property } = cc._decorator; @ccclass -export default class GaussianBlurEffectScene extends cc.Component { - private _grayLevelSlider: cc.Slider = null; - private _grayLevelSliderLabel: cc.Label = null; +export default class GaussianBlurV1EffectScene extends cc.Component { + private _blurSlider: cc.Slider = null; + private _blurSliderLabel: cc.Label = null; private _examplesParentNode: cc.Node = null; onLoad() { cc.dynamicAtlasManager.enabled = false; - this._grayLevelSlider = cc.find("Canvas/Content/Controller/GrayLevelSlider/Slider").getComponent(cc.Slider); - this._grayLevelSliderLabel = cc.find("Canvas/Content/Controller/GrayLevelSlider/ValueLabel").getComponent(cc.Label); + this._blurSlider = cc.find("Canvas/Content/Controller/BlurSlider/Slider").getComponent(cc.Slider); + this._blurSliderLabel = cc.find("Canvas/Content/Controller/BlurSlider/ValueLabel").getComponent(cc.Label); this._examplesParentNode = cc.find("Canvas/Content/Examples"); } onEnable() { - this._grayLevelSlider.node.on("slide", this._onSliderChanged, this); + this._blurSlider.node.on("slide", this._onSliderChanged, this); } onDisable() { - this._grayLevelSlider.node.off("slide", this._onSliderChanged, this); + this._blurSlider.node.off("slide", this._onSliderChanged, this); } start() { @@ -29,7 +29,7 @@ export default class GaussianBlurEffectScene extends cc.Component { } private _onSliderChanged() { - this._grayLevelSliderLabel.string = `${this._grayLevelSlider.progress.toFixed(2)}`; + this._blurSliderLabel.string = `${this._blurSlider.progress.toFixed(2)}`; // 更新材质 this._updateRenderComponentMaterial({}); diff --git a/assets/scripts/GaussianBlurEffectScene.ts.meta b/assets/scripts/GaussianBlurV1EffectScene.ts.meta similarity index 100% rename from assets/scripts/GaussianBlurEffectScene.ts.meta rename to assets/scripts/GaussianBlurV1EffectScene.ts.meta