加入迷雾控制

This commit is contained in:
caizhitao 2020-01-12 08:05:29 +08:00
parent ba90b2170c
commit 9f28ef4305
5 changed files with 655 additions and 59 deletions

View File

@ -105,8 +105,12 @@ CCProgram fs %{
float radius;
// 裁剪掉透明区域上的点光
// ps编辑器还不支持 bool 类型的样子,因此没在 CCEffect 中定义 cropAlpha
// ps编辑器还不支持 bool 类型的样子,因此没在 CCEffect 中定义
bool cropAlpha;
// 是否启用迷雾效果
// ps编辑器还不支持 bool 类型的样子,因此没在 CCEffect 中定义
bool enableFog;
}
/**
@ -123,8 +127,10 @@ CCProgram fs %{
a *= step(0.01, textureColor.a);
}
// 裁剪掉扩散范围外的uv
// a *= step(dis, radius);
// 裁剪掉扩散范围外的uv迷雾效果
if (!enableFog) {
a *= step(dis, radius);
}
// 加入从中心往外渐变的效果
a *= 1.0 - (dis / radius);

View File

@ -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 ENABLE_DIFFUSION\nuniform vec4 centerColor;\nuniform vec2 centerPoint;\nuniform float radius;\nuniform bool cropAlpha;\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 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 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"
},
"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_DIFFUSION\nuniform Diffusion {\n\n vec4 centerColor;\n\n vec2 centerPoint;\n\n float radius;\n\n bool cropAlpha;\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 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 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"
}
}
],

View File

@ -78,10 +78,10 @@
"_active": true,
"_components": [
{
"__id__": 125
"__id__": 137
},
{
"__id__": 126
"__id__": 138
}
],
"_prefab": null,
@ -171,7 +171,7 @@
"array": [
0,
0,
492.7684547533456,
491.0364039457767,
0,
0,
0,
@ -245,13 +245,13 @@
"__id__": 9
},
{
"__id__": 109
"__id__": 121
}
],
"_active": true,
"_components": [
{
"__id__": 124
"__id__": 136
}
],
"_prefab": null,
@ -451,15 +451,18 @@
},
{
"__id__": 95
},
{
"__id__": 107
}
],
"_active": true,
"_components": [
{
"__id__": 107
"__id__": 119
},
{
"__id__": 108
"__id__": 120
}
],
"_prefab": null,
@ -474,7 +477,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 576,
"height": 540
"height": 480
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@ -1319,7 +1322,7 @@
"ctor": "Float64Array",
"array": [
0,
-126,
-100,
0,
0,
0,
@ -2080,7 +2083,7 @@
"ctor": "Float64Array",
"array": [
0,
-222,
-170,
0,
0,
0,
@ -2841,7 +2844,7 @@
"ctor": "Float64Array",
"array": [
0,
-318,
-240,
0,
0,
0,
@ -3602,7 +3605,7 @@
"ctor": "Float64Array",
"array": [
0,
-414,
-310,
0,
0,
0,
@ -4360,7 +4363,7 @@
"ctor": "Float64Array",
"array": [
0,
-510,
-380,
0,
0,
0,
@ -4898,6 +4901,589 @@
"_originalHeight": 0,
"_id": "efiFYhAgxFpY9khUf6wQ/S"
},
{
"__type__": "cc.Node",
"_name": "EnableFogToggle",
"_objFlags": 0,
"_parent": {
"__id__": 9
},
"_children": [
{
"__id__": 108
},
{
"__id__": 111
}
],
"_active": true,
"_components": [
{
"__id__": 118
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 576,
"height": 60
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
-450,
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": "76vm3aJ6RBJJV/ObsptXAg"
},
{
"__type__": "cc.Node",
"_name": "DescLabel",
"_objFlags": 0,
"_parent": {
"__id__": 107
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 109
},
{
"__id__": 110
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 432,
"height": 40
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 1,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
144,
0,
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": "39faOmDqFEF45qoB99qGG8"
},
{
"__type__": "cc.Label",
"_name": "SliderDescLabel<Label>",
"_objFlags": 0,
"node": {
"__id__": 108
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_useOriginalSize": false,
"_string": "启用迷雾效果:",
"_N$string": "启用迷雾效果:",
"_fontSize": 40,
"_lineHeight": 40,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_N$horizontalAlign": 0,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 2,
"_N$cacheMode": 0,
"_id": "72bn8MBPlJub9703i57OuY"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 108
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 0,
"_right": 0.25,
"_top": 10,
"_bottom": 10,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": false,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 113.38,
"_originalHeight": 50.4,
"_id": "c8mkfeqR9NUZu8Cz/2SPbO"
},
{
"__type__": "cc.Node",
"_name": "Toggle",
"_objFlags": 0,
"_parent": {
"__id__": 107
},
"_children": [
{
"__id__": 112
},
{
"__id__": 114
}
],
"_active": true,
"_components": [
{
"__id__": 116
},
{
"__id__": 117
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 28,
"height": 28
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
158,
0,
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": "21L/wEbjdNUYyJ9y4SbFFH"
},
{
"__type__": "cc.Node",
"_name": "Background",
"_objFlags": 0,
"_parent": {
"__id__": 111
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 113
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 28,
"height": 28
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
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": "f7RlBAbBNJNbmEm3chl062"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 112
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "6827ca32-0107-4552-bab2-dfb31799bb44"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "d6Isoo7/ZO/bbOhEvqBb0k"
},
{
"__type__": "cc.Node",
"_name": "checkmark",
"_objFlags": 0,
"_parent": {
"__id__": 111
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 115
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 28,
"height": 28
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
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": "09QL6g+ENK5oeAI3eRiFkZ"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 114
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "90004ad6-2f6d-40e1-93ef-b714375c6f06"
},
"_type": 0,
"_sizeMode": 2,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": false,
"_atlas": null,
"_id": "40fLjBd/9DJKek7+KSubyW"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 111
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 8,
"_left": 0.75,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": false,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "9fBwpoEbhJ6ZQE7B47Ub6L"
},
{
"__type__": "cc.Toggle",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 111
},
"_enabled": true,
"_normalMaterial": {
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
},
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 3,
"transition": 3,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 214,
"g": 214,
"b": 214,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": {
"__id__": 112
},
"_N$isChecked": false,
"toggleGroup": null,
"checkMark": {
"__id__": 115
},
"checkEvents": [],
"_id": "11XOk3zDJLfZvBbfeWPiSh"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 107
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 40,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 461.38,
"_originalHeight": 0,
"_id": "4eONhDOstGwr5Sg+FM0KX0"
},
{
"__type__": "cc.Widget",
"_name": "",
@ -4936,7 +5522,7 @@
"_layoutSize": {
"__type__": "cc.Size",
"width": 576,
"height": 540
"height": 480
},
"_resize": 1,
"_N$layoutType": 2,
@ -4952,7 +5538,7 @@
"_N$paddingTop": 0,
"_N$paddingBottom": 0,
"_N$spacingX": 0,
"_N$spacingY": 36,
"_N$spacingY": 10,
"_N$verticalDirection": 1,
"_N$horizontalDirection": 0,
"_N$affectedByScale": false,
@ -4967,31 +5553,31 @@
},
"_children": [
{
"__id__": 110
"__id__": 122
},
{
"__id__": 112
"__id__": 124
},
{
"__id__": 114
"__id__": 126
},
{
"__id__": 116
"__id__": 128
},
{
"__id__": 118
"__id__": 130
},
{
"__id__": 120
"__id__": 132
}
],
"_active": true,
"_components": [
{
"__id__": 122
"__id__": 134
},
{
"__id__": 123
"__id__": 135
}
],
"_prefab": null,
@ -5047,13 +5633,13 @@
"_name": "ball_0",
"_objFlags": 0,
"_parent": {
"__id__": 109
"__id__": 121
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 111
"__id__": 123
}
],
"_prefab": null,
@ -5109,7 +5695,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 110
"__id__": 122
},
"_enabled": true,
"_materials": [
@ -5141,13 +5727,13 @@
"_name": "cocos_logo",
"_objFlags": 0,
"_parent": {
"__id__": 109
"__id__": 121
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 113
"__id__": 125
}
],
"_prefab": null,
@ -5203,7 +5789,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 112
"__id__": 124
},
"_enabled": true,
"_materials": [
@ -5235,13 +5821,13 @@
"_name": "ball_1",
"_objFlags": 0,
"_parent": {
"__id__": 109
"__id__": 121
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 115
"__id__": 127
}
],
"_prefab": null,
@ -5297,7 +5883,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 114
"__id__": 126
},
"_enabled": true,
"_materials": [
@ -5329,13 +5915,13 @@
"_name": "video_btn",
"_objFlags": 0,
"_parent": {
"__id__": 109
"__id__": 121
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 117
"__id__": 129
}
],
"_prefab": null,
@ -5391,7 +5977,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 116
"__id__": 128
},
"_enabled": true,
"_materials": [
@ -5423,13 +6009,13 @@
"_name": "SystemFont",
"_objFlags": 0,
"_parent": {
"__id__": 109
"__id__": 121
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 119
"__id__": 131
}
],
"_prefab": null,
@ -5485,7 +6071,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 118
"__id__": 130
},
"_enabled": true,
"_materials": [
@ -5515,13 +6101,13 @@
"_name": "BmFont",
"_objFlags": 0,
"_parent": {
"__id__": 109
"__id__": 121
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 121
"__id__": 133
}
],
"_prefab": null,
@ -5577,7 +6163,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 120
"__id__": 132
},
"_enabled": true,
"_materials": [
@ -5609,7 +6195,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 109
"__id__": 121
},
"_enabled": true,
"alignMode": 1,
@ -5636,7 +6222,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 109
"__id__": 121
},
"_enabled": true,
"_layoutSize": {

View File

@ -38,6 +38,7 @@ export default class LocalDiffusionCtrl extends cc.Component {
this._localDiffusionUniform.centerColor = localDiffusionUniform.centerColor;
this._localDiffusionUniform.radius = localDiffusionUniform.radius;
this._localDiffusionUniform.cropAlpha = localDiffusionUniform.cropAlpha;
this._localDiffusionUniform.enableFog = localDiffusionUniform.enableFog;
this._updateMaterial();
}
@ -48,6 +49,7 @@ export default class LocalDiffusionCtrl extends cc.Component {
material.setProperty("centerPoint", this._localDiffusionUniform.certerPoint);
material.setProperty("radius", this._localDiffusionUniform.radius);
material.setProperty("cropAlpha", this._localDiffusionUniform.cropAlpha);
material.setProperty("enableFog", this._localDiffusionUniform.enableFog);
renderComponent.setMaterial(0, material);
});
}
@ -73,4 +75,9 @@ export class LocalDiffusionUniform {
*
*/
cropAlpha: boolean = true;
/**
*
*/
enableFog: boolean = false;
}

View File

@ -6,20 +6,17 @@ const { ccclass, property } = cc._decorator;
export default class LocalDiffusionEffectScene 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 _radiuSlider: cc.Slider = null;
private _radiuSliderLabel: cc.Label = null;
private _cropAlphaToggle: cc.Toggle = null;
private _enableFogToggle: cc.Toggle = null;
private _examplesParentNode: cc.Node = null;
@ -28,20 +25,17 @@ export default class LocalDiffusionEffectScene extends cc.Component {
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._radiuSlider = cc.find("Canvas/Content/Controller/RadiuSlider/Slider").getComponent(cc.Slider);
this._radiuSliderLabel = cc.find("Canvas/Content/Controller/RadiuSlider/ValueLabel").getComponent(cc.Label);
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");
@ -57,6 +51,7 @@ export default class LocalDiffusionEffectScene extends cc.Component {
this._alphaSlider.node.on("slide", this._onPropertyChanged, this);
this._radiuSlider.node.on("slide", this._onPropertyChanged, this);
this._cropAlphaToggle.node.on("toggle", this._onPropertyChanged, this);
this._enableFogToggle.node.on("toggle", this._onPropertyChanged, this);
}
onDisable() {
@ -66,6 +61,7 @@ export default class LocalDiffusionEffectScene extends cc.Component {
this._alphaSlider.node.off("slide", this._onPropertyChanged, this);
this._radiuSlider.node.off("slide", this._onPropertyChanged, this);
this._cropAlphaToggle.node.off("toggle", this._onPropertyChanged, this);
this._enableFogToggle.node.off("toggle", this._onPropertyChanged, this);
}
start() {
@ -90,7 +86,8 @@ export default class LocalDiffusionEffectScene extends cc.Component {
Math.round(255 * this._alphaSlider.progress)
),
radius: this._radiuSlider.progress,
cropAlpha: this._cropAlphaToggle.isChecked
cropAlpha: this._cropAlphaToggle.isChecked,
enableFog: this._enableFogToggle.isChecked
});
});
}