├── .gitignore
├── README.md
├── assets
├── case.meta
├── case
│ ├── 01_spirteOutline.meta
│ ├── 01_spirteOutline
│ │ ├── spirteOutline.effect
│ │ ├── spirteOutline.effect.meta
│ │ ├── spirteOutline.mtl
│ │ ├── spirteOutline.mtl.meta
│ │ ├── spirteOutline.scene
│ │ ├── spirteOutline.scene.meta
│ │ ├── spirteOutline.ts
│ │ └── spirteOutline.ts.meta
│ ├── 02_blur.meta
│ ├── 02_blur
│ │ ├── blur.effect
│ │ ├── blur.effect.meta
│ │ ├── blur.mtl
│ │ ├── blur.mtl.meta
│ │ ├── blur.scene
│ │ ├── blur.scene.meta
│ │ ├── blur.ts
│ │ └── blur.ts.meta
│ ├── 03_flash.meta
│ ├── 03_flash
│ │ ├── flash.effect
│ │ ├── flash.effect.meta
│ │ ├── flash.mtl
│ │ ├── flash.mtl.meta
│ │ ├── flash.scene
│ │ ├── flash.scene.meta
│ │ ├── flash.ts
│ │ └── flash.ts.meta
│ ├── 04_shadow.meta
│ ├── 04_shadow
│ │ ├── shadow.effect
│ │ ├── shadow.effect.meta
│ │ ├── shadow.mtl
│ │ ├── shadow.mtl.meta
│ │ ├── shadow.scene
│ │ ├── shadow.scene.meta
│ │ ├── shadow.ts
│ │ └── shadow.ts.meta
│ ├── 05_gaussBlur.meta
│ ├── 05_gaussBlur
│ │ ├── gaussBlur.effect
│ │ ├── gaussBlur.effect.meta
│ │ ├── gaussBlur.mtl
│ │ ├── gaussBlur.mtl.meta
│ │ ├── gaussBlur.scene
│ │ ├── gaussBlur.scene.meta
│ │ ├── gaussBlur.ts
│ │ └── gaussBlur.ts.meta
│ ├── 06_waterWave.meta
│ ├── 06_waterWave
│ │ ├── waterWave.effect
│ │ ├── waterWave.effect.meta
│ │ ├── waterWave.mtl
│ │ ├── waterWave.mtl.meta
│ │ ├── waterWave.scene
│ │ ├── waterWave.scene.meta
│ │ ├── waterWave.ts
│ │ └── waterWave.ts.meta
│ ├── 07_waterRipple.meta
│ ├── 07_waterRipple
│ │ ├── waterRipple.effect
│ │ ├── waterRipple.effect.meta
│ │ ├── waterRipple.mtl
│ │ ├── waterRipple.mtl.meta
│ │ ├── waterRipple.scene
│ │ ├── waterRipple.scene.meta
│ │ ├── waterRipple.ts
│ │ └── waterRipple.ts.meta
│ ├── 08_radius.meta
│ └── 08_radius
│ │ ├── radius.effect
│ │ ├── radius.effect.meta
│ │ ├── radius.mtl
│ │ ├── radius.mtl.meta
│ │ ├── radius.scene
│ │ ├── radius.scene.meta
│ │ ├── radius.ts
│ │ └── radius.ts.meta
├── migrate-resources.meta
├── migrate-resources
│ ├── chunks.meta
│ └── chunks
│ │ ├── cc-lights.chunk
│ │ ├── cc-lights.chunk.meta
│ │ ├── decode-base.chunk
│ │ ├── decode-base.chunk.meta
│ │ ├── phong-fs.chunk
│ │ ├── phong-fs.chunk.meta
│ │ ├── phong-vs.chunk
│ │ ├── phong-vs.chunk.meta
│ │ ├── shading-phong.chunk
│ │ ├── shading-phong.chunk.meta
│ │ ├── shading-toon.chunk
│ │ ├── shading-toon.chunk.meta
│ │ ├── texture.chunk
│ │ ├── texture.chunk.meta
│ │ ├── unlit-fs.chunk
│ │ ├── unlit-fs.chunk.meta
│ │ ├── unlit-vs.chunk
│ │ ├── unlit-vs.chunk.meta
│ │ ├── unpack.chunk
│ │ └── unpack.chunk.meta
├── scene.scene
├── scene.scene.meta
├── texture.meta
├── texture
│ ├── Fort_1.png
│ ├── Fort_1.png.meta
│ ├── Fort_60.png
│ ├── Fort_60.png.meta
│ ├── gun-1.png
│ ├── gun-1.png.meta
│ ├── image.jpg
│ ├── image.jpg.meta
│ ├── img-01.jpg
│ ├── img-01.jpg.meta
│ ├── wave.png
│ └── wave.png.meta
├── utils.meta
└── utils
│ ├── cocosHack.ts
│ ├── cocosHack.ts.meta
│ ├── utils.ts
│ └── utils.ts.meta
├── package.json
├── preview
├── flash.png
├── gaussBlur.png
├── shadow.png
├── spriteOutline.png
├── waterRipple.gif
└── waterWave.gif
├── settings
└── v2
│ └── packages
│ ├── builder.json
│ ├── cocos-service.json
│ ├── engine.json
│ └── project.json
└── tsconfig.json
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | #///////////////////////////
3 | # Cocos Creator 3D Project
4 | #///////////////////////////
5 | library/
6 | temp/
7 | local/
8 | build/
9 | profiles/
10 | native
11 | #//////////////////////////
12 | # NPM
13 | #//////////////////////////
14 | node_modules/
15 |
16 | #//////////////////////////
17 | # VSCode
18 | #//////////////////////////
19 | .vscode/
20 |
21 | #//////////////////////////
22 | # WebStorm
23 | #//////////////////////////
24 | .idea/
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Cocos creater shader demos
2 | Cocos creator project.Based on material system.
3 | Current version 3.6.0.
4 | (旧版的 3.0.0, 2.4.2 版本我打了 Tag ,点击右侧边栏的 Releases - tags 展开)
5 |
6 |
7 | ## 01_spirteOutline 轮廓线
8 |
9 | ## 02_blur 模糊效果
10 | 我不觉得有人需要这个效果,这个太丑了,所以我删掉了它节省你的流量,05 高斯模糊可能是你想要的效果
11 | ## 03_flash 流光
12 |
13 | ## 04_shadow 投影
14 |
15 | ## 05_gaussBlur 高斯模糊
16 |
17 | ## 06_waterWave 水波
18 |
19 | ## 07_waterRipple 水滴波纹
20 |
21 |
22 | This is my favorite!
23 | 效果非常棒,变形函数来自 dtysky。
24 | ## 08_radius 圆角
25 | 这个大概不需要放图了吧
26 |
27 | ### ps:案例多数是我从网络上公开区域收集来的,非原创,仅供个人学习之用。
28 |
--------------------------------------------------------------------------------
/assets/case.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.0",
3 | "importer": "directory",
4 | "imported": true,
5 | "uuid": "a7ccf4bb-3f17-4c4a-bfe5-d87789873bda",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "compressionType": {},
10 | "isRemoteBundle": {}
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/assets/case/01_spirteOutline.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.0",
3 | "importer": "directory",
4 | "imported": true,
5 | "uuid": "7255d5f7-11db-484d-8361-7174dcd4ecb7",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "compressionType": {},
10 | "isRemoteBundle": {}
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/assets/case/01_spirteOutline/spirteOutline.effect:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
2 | CCEffect %{
3 | techniques:
4 | - passes:
5 | - vert: sprite-vs:vert
6 | frag: sprite-fs:frag
7 | depthStencilState:
8 | depthTest: false
9 | depthWrite: false
10 | blendState:
11 | targets:
12 | - blend: true
13 | blendSrc: src_alpha
14 | blendDst: one_minus_src_alpha
15 | blendDstAlpha: one_minus_src_alpha
16 | rasterizerState:
17 | cullMode: none
18 | properties:
19 | alphaThreshold: { value: 0.5 }
20 | outlineColor: { value: [1.0, 1.0, 1.0, 1.0], editor: { type: color } }
21 | textureSize: { value: [300.0, 200.0] }
22 | outlineSize: { value: 5.0 }
23 | }%
24 |
25 | CCProgram sprite-vs %{
26 | precision highp float;
27 | #include
28 | #if USE_LOCAL
29 | #include
30 | #endif
31 |
32 | in vec3 a_position;
33 | in vec2 a_texCoord;
34 | in vec4 a_color;
35 |
36 | out vec4 color;
37 | out vec2 uv0;
38 |
39 | vec4 vert () {
40 | vec4 pos = vec4(a_position, 1);
41 |
42 | #if USE_LOCAL
43 | pos = cc_matWorld * pos;
44 | #endif
45 |
46 | #if USE_PIXEL_ALIGNMENT
47 | pos = cc_matView * pos;
48 | pos.xyz = floor(pos.xyz);
49 | pos = cc_matProj * pos;
50 | #else
51 | pos = cc_matViewProj * pos;
52 | #endif
53 |
54 | uv0 = a_texCoord;
55 |
56 | color = a_color;
57 |
58 | return pos;
59 | }
60 | }%
61 |
62 | CCProgram sprite-fs %{
63 | precision highp float;
64 | #include
65 | #include
66 |
67 | in vec4 color;
68 |
69 | #if USE_TEXTURE
70 | in vec2 uv0;
71 | #pragma builtin(local)
72 | layout(set = 2, binding = 10) uniform sampler2D cc_spriteTexture;
73 | #endif
74 |
75 | uniform FragConstants {
76 | vec4 outlineColor;
77 | vec2 textureSize;
78 | float outlineSize;
79 | };
80 |
81 | int getIsStrokeWithAngel(float angel) {
82 | int stroke = 0;
83 | float rad = angel * 0.01745329252;
84 | float a = CCSampleWithAlphaSeparated(cc_spriteTexture, vec2(uv0.x + outlineSize * cos(rad) / textureSize.x, uv0.y + outlineSize * sin(rad) / textureSize.y)).a;
85 | if (a >= 0.5)
86 | {
87 | stroke = 1;
88 | }
89 | return stroke;
90 | }
91 |
92 | vec4 frag () {
93 | vec4 o = vec4(1, 1, 1, 1);
94 |
95 | #if USE_TEXTURE
96 | o *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0);
97 | #endif
98 |
99 | if (o.a >= 0.5)
100 | {
101 | return color * o;
102 | }
103 | int strokeCount = 0;
104 | strokeCount += getIsStrokeWithAngel(0.0);
105 | strokeCount += getIsStrokeWithAngel(30.0);
106 | strokeCount += getIsStrokeWithAngel(60.0);
107 | strokeCount += getIsStrokeWithAngel(90.0);
108 | strokeCount += getIsStrokeWithAngel(120.0);
109 | strokeCount += getIsStrokeWithAngel(150.0);
110 | strokeCount += getIsStrokeWithAngel(180.0);
111 | strokeCount += getIsStrokeWithAngel(210.0);
112 | strokeCount += getIsStrokeWithAngel(240.0);
113 | strokeCount += getIsStrokeWithAngel(270.0);
114 | strokeCount += getIsStrokeWithAngel(300.0);
115 | strokeCount += getIsStrokeWithAngel(330.0);
116 |
117 | if (strokeCount > 0)
118 | {
119 | o.rgba = outlineColor;
120 | o.a = 1.0;
121 | }
122 |
123 | // o *= color;
124 | ALPHA_TEST(o);
125 | return o;
126 | }
127 | }%
128 |
--------------------------------------------------------------------------------
/assets/case/01_spirteOutline/spirteOutline.effect.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.5.9",
3 | "importer": "effect",
4 | "imported": true,
5 | "uuid": "286b8bec-a24a-42d6-8534-d7195c590b00",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/01_spirteOutline/spirteOutline.mtl:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.Material",
3 | "_name": "",
4 | "_objFlags": 0,
5 | "_native": "",
6 | "_effectAsset": {
7 | "__uuid__": "286b8bec-a24a-42d6-8534-d7195c590b00"
8 | },
9 | "_techIdx": 0,
10 | "_defines": [
11 | {
12 | "USE_TEXTURE": true
13 | }
14 | ],
15 | "_states": [
16 | {
17 | "rasterizerState": {},
18 | "depthStencilState": {},
19 | "blendState": {
20 | "targets": [
21 | {}
22 | ]
23 | }
24 | }
25 | ],
26 | "_props": [
27 | {}
28 | ]
29 | }
--------------------------------------------------------------------------------
/assets/case/01_spirteOutline/spirteOutline.mtl.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.13",
3 | "importer": "material",
4 | "imported": true,
5 | "uuid": "5fff14db-2f77-4d6a-9f22-cfff5686b1c8",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/01_spirteOutline/spirteOutline.scene:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.SceneAsset",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "scene": {
8 | "__id__": 1
9 | }
10 | },
11 | {
12 | "__type__": "cc.Scene",
13 | "_name": "spirteOutline",
14 | "_objFlags": 0,
15 | "_parent": null,
16 | "_children": [
17 | {
18 | "__id__": 2
19 | }
20 | ],
21 | "_active": true,
22 | "_components": [],
23 | "_prefab": {
24 | "__id__": 21
25 | },
26 | "autoReleaseAssets": false,
27 | "_globals": {
28 | "__id__": 22
29 | },
30 | "_id": "35aafe0d-9c5c-4287-b97b-add9203ff4a5"
31 | },
32 | {
33 | "__type__": "cc.Node",
34 | "_name": "Canvas",
35 | "_objFlags": 0,
36 | "_parent": {
37 | "__id__": 1
38 | },
39 | "_children": [
40 | {
41 | "__id__": 3
42 | },
43 | {
44 | "__id__": 7
45 | },
46 | {
47 | "__id__": 12
48 | }
49 | ],
50 | "_active": true,
51 | "_components": [
52 | {
53 | "__id__": 17
54 | },
55 | {
56 | "__id__": 18
57 | },
58 | {
59 | "__id__": 19
60 | },
61 | {
62 | "__id__": 20
63 | }
64 | ],
65 | "_prefab": null,
66 | "_lpos": {
67 | "__type__": "cc.Vec3",
68 | "x": 480,
69 | "y": 320,
70 | "z": 0
71 | },
72 | "_lrot": {
73 | "__type__": "cc.Quat",
74 | "x": 0,
75 | "y": 0,
76 | "z": 0,
77 | "w": 1
78 | },
79 | "_lscale": {
80 | "__type__": "cc.Vec3",
81 | "x": 1,
82 | "y": 1,
83 | "z": 1
84 | },
85 | "_layer": 1,
86 | "_euler": {
87 | "__type__": "cc.Vec3",
88 | "x": 0,
89 | "y": 0,
90 | "z": 0
91 | },
92 | "_id": "d6Ngmh6ZRGFJLRuR75koHM"
93 | },
94 | {
95 | "__type__": "cc.Node",
96 | "_name": "Main Camera",
97 | "_objFlags": 0,
98 | "_parent": {
99 | "__id__": 2
100 | },
101 | "_children": [],
102 | "_active": true,
103 | "_components": [
104 | {
105 | "__id__": 4
106 | },
107 | {
108 | "__id__": 5
109 | },
110 | {
111 | "__id__": 6
112 | }
113 | ],
114 | "_prefab": null,
115 | "_lpos": {
116 | "__type__": "cc.Vec3",
117 | "x": 0,
118 | "y": 0,
119 | "z": 1000
120 | },
121 | "_lrot": {
122 | "__type__": "cc.Quat",
123 | "x": 0,
124 | "y": 0,
125 | "z": 0,
126 | "w": 1
127 | },
128 | "_lscale": {
129 | "__type__": "cc.Vec3",
130 | "x": 1,
131 | "y": 1,
132 | "z": 1
133 | },
134 | "_layer": 1,
135 | "_euler": {
136 | "__type__": "cc.Vec3",
137 | "x": 0,
138 | "y": 0,
139 | "z": 0
140 | },
141 | "_id": "famfQa9lNNDpy1laptVx12"
142 | },
143 | {
144 | "__type__": "cc.Camera",
145 | "_name": "",
146 | "_objFlags": 0,
147 | "node": {
148 | "__id__": 3
149 | },
150 | "_enabled": true,
151 | "__prefab": null,
152 | "_projection": 0,
153 | "_priority": -1,
154 | "_fov": 60,
155 | "_fovAxis": 0,
156 | "_orthoHeight": 426.31989596879066,
157 | "_near": 1,
158 | "_far": 4096,
159 | "_color": {
160 | "__type__": "cc.Color",
161 | "r": 0,
162 | "g": 0,
163 | "b": 0,
164 | "a": 255
165 | },
166 | "_depth": 1,
167 | "_stencil": 0,
168 | "_clearFlags": 7,
169 | "_rect": {
170 | "__type__": "cc.Rect",
171 | "x": 0,
172 | "y": 0,
173 | "width": 1,
174 | "height": 1
175 | },
176 | "_aperture": 19,
177 | "_shutter": 7,
178 | "_iso": 0,
179 | "_screenScale": 1,
180 | "_visibility": 4294967295,
181 | "_targetTexture": null,
182 | "_id": "12FxhQCQhKjLi1OSAfGzBd"
183 | },
184 | {
185 | "__type__": "cc.UIOpacity",
186 | "_name": "",
187 | "_objFlags": 0,
188 | "node": {
189 | "__id__": 3
190 | },
191 | "_enabled": true,
192 | "__prefab": null,
193 | "_opacity": 255,
194 | "_id": "47L56DFI1Gcaged+Sbjuwd"
195 | },
196 | {
197 | "__type__": "cc.UITransform",
198 | "_name": "",
199 | "_objFlags": 0,
200 | "node": {
201 | "__id__": 3
202 | },
203 | "_enabled": true,
204 | "__prefab": null,
205 | "_contentSize": {
206 | "__type__": "cc.Size",
207 | "width": 0,
208 | "height": 0
209 | },
210 | "_anchorPoint": {
211 | "__type__": "cc.Vec2",
212 | "x": 0.5,
213 | "y": 0.5
214 | },
215 | "_id": "78y4AaNrxPk4KE6gPuv6Su"
216 | },
217 | {
218 | "__type__": "cc.Node",
219 | "_name": "bg",
220 | "_objFlags": 0,
221 | "_parent": {
222 | "__id__": 2
223 | },
224 | "_children": [],
225 | "_active": true,
226 | "_components": [
227 | {
228 | "__id__": 8
229 | },
230 | {
231 | "__id__": 9
232 | },
233 | {
234 | "__id__": 10
235 | },
236 | {
237 | "__id__": 11
238 | }
239 | ],
240 | "_prefab": null,
241 | "_lpos": {
242 | "__type__": "cc.Vec3",
243 | "x": 0,
244 | "y": 0,
245 | "z": 0
246 | },
247 | "_lrot": {
248 | "__type__": "cc.Quat",
249 | "x": 0,
250 | "y": 0,
251 | "z": 0,
252 | "w": 1
253 | },
254 | "_lscale": {
255 | "__type__": "cc.Vec3",
256 | "x": 1,
257 | "y": 1,
258 | "z": 1
259 | },
260 | "_layer": 1,
261 | "_euler": {
262 | "__type__": "cc.Vec3",
263 | "x": 0,
264 | "y": 0,
265 | "z": 0
266 | },
267 | "_id": "2fUVfrgY9NRrX+cio35bw9"
268 | },
269 | {
270 | "__type__": "cc.Sprite",
271 | "_name": "",
272 | "_objFlags": 0,
273 | "node": {
274 | "__id__": 7
275 | },
276 | "_enabled": true,
277 | "__prefab": null,
278 | "_customMaterial": null,
279 | "_srcBlendFactor": 2,
280 | "_dstBlendFactor": 4,
281 | "_color": {
282 | "__type__": "cc.Color",
283 | "r": 0,
284 | "g": 0,
285 | "b": 0,
286 | "a": 255
287 | },
288 | "_spriteFrame": {
289 | "__uuid__": "7d8f9b89-4fd1-4c9f-a3ab-38ec7cded7ca@f9941",
290 | "__expectedType__": "cc.SpriteFrame"
291 | },
292 | "_type": 0,
293 | "_fillType": 0,
294 | "_sizeMode": 0,
295 | "_fillCenter": {
296 | "__type__": "cc.Vec2",
297 | "x": 0,
298 | "y": 0
299 | },
300 | "_fillStart": 0,
301 | "_fillRange": 0,
302 | "_isTrimmedMode": false,
303 | "_useGrayscale": false,
304 | "_atlas": null,
305 | "_id": "61LUH7tyhDp4a/rKjWDA4V"
306 | },
307 | {
308 | "__type__": "cc.Widget",
309 | "_name": "",
310 | "_objFlags": 0,
311 | "node": {
312 | "__id__": 7
313 | },
314 | "_enabled": true,
315 | "__prefab": null,
316 | "_alignFlags": 45,
317 | "_target": null,
318 | "_left": 0,
319 | "_right": 0,
320 | "_top": 0,
321 | "_bottom": 0,
322 | "_horizontalCenter": 0,
323 | "_verticalCenter": 0,
324 | "_isAbsLeft": true,
325 | "_isAbsRight": true,
326 | "_isAbsTop": true,
327 | "_isAbsBottom": true,
328 | "_isAbsHorizontalCenter": true,
329 | "_isAbsVerticalCenter": true,
330 | "_originalWidth": 100,
331 | "_originalHeight": 100,
332 | "_alignMode": 2,
333 | "_lockFlags": 0,
334 | "_id": "58V7iCpjZLb7A5Z9/SI9eo"
335 | },
336 | {
337 | "__type__": "cc.UIOpacity",
338 | "_name": "",
339 | "_objFlags": 0,
340 | "node": {
341 | "__id__": 7
342 | },
343 | "_enabled": true,
344 | "__prefab": null,
345 | "_opacity": 255,
346 | "_id": "09hRZLwZpPbrwFdWJyvElu"
347 | },
348 | {
349 | "__type__": "cc.UITransform",
350 | "_name": "",
351 | "_objFlags": 0,
352 | "node": {
353 | "__id__": 7
354 | },
355 | "_enabled": true,
356 | "__prefab": null,
357 | "_contentSize": {
358 | "__type__": "cc.Size",
359 | "width": 960,
360 | "height": 640
361 | },
362 | "_anchorPoint": {
363 | "__type__": "cc.Vec2",
364 | "x": 0.5,
365 | "y": 0.5
366 | },
367 | "_id": "d8MAsW5LlB36+z5UwMJP5Z"
368 | },
369 | {
370 | "__type__": "cc.Node",
371 | "_name": "img_fort",
372 | "_objFlags": 0,
373 | "_parent": {
374 | "__id__": 2
375 | },
376 | "_children": [],
377 | "_active": true,
378 | "_components": [
379 | {
380 | "__id__": 13
381 | },
382 | {
383 | "__id__": 14
384 | },
385 | {
386 | "__id__": 15
387 | },
388 | {
389 | "__id__": 16
390 | }
391 | ],
392 | "_prefab": null,
393 | "_lpos": {
394 | "__type__": "cc.Vec3",
395 | "x": 0,
396 | "y": 0,
397 | "z": 0
398 | },
399 | "_lrot": {
400 | "__type__": "cc.Quat",
401 | "x": 0,
402 | "y": 0,
403 | "z": 0,
404 | "w": 1
405 | },
406 | "_lscale": {
407 | "__type__": "cc.Vec3",
408 | "x": 1,
409 | "y": 1,
410 | "z": 1
411 | },
412 | "_layer": 1,
413 | "_euler": {
414 | "__type__": "cc.Vec3",
415 | "x": 0,
416 | "y": 0,
417 | "z": 0
418 | },
419 | "_id": "56HYDPtjRMgoZVxF733D5Y"
420 | },
421 | {
422 | "__type__": "cc.Sprite",
423 | "_name": "",
424 | "_objFlags": 0,
425 | "node": {
426 | "__id__": 12
427 | },
428 | "_enabled": true,
429 | "__prefab": null,
430 | "_customMaterial": {
431 | "__uuid__": "5fff14db-2f77-4d6a-9f22-cfff5686b1c8",
432 | "__expectedType__": "cc.Material"
433 | },
434 | "_srcBlendFactor": 2,
435 | "_dstBlendFactor": 4,
436 | "_color": {
437 | "__type__": "cc.Color",
438 | "r": 255,
439 | "g": 255,
440 | "b": 255,
441 | "a": 255
442 | },
443 | "_spriteFrame": {
444 | "__uuid__": "b99ff1e7-ac1e-4e2c-80a9-b0ae8fccab8a@f9941",
445 | "__expectedType__": "cc.SpriteFrame"
446 | },
447 | "_type": 0,
448 | "_fillType": 0,
449 | "_sizeMode": 0,
450 | "_fillCenter": {
451 | "__type__": "cc.Vec2",
452 | "x": 0,
453 | "y": 0
454 | },
455 | "_fillStart": 0,
456 | "_fillRange": 0,
457 | "_isTrimmedMode": false,
458 | "_useGrayscale": false,
459 | "_atlas": null,
460 | "_id": "0avbX6WYtCQIPhcpBZwtNg"
461 | },
462 | {
463 | "__type__": "c5024nKazFMSoN6GTgsHdkO",
464 | "_name": "",
465 | "_objFlags": 0,
466 | "node": {
467 | "__id__": 12
468 | },
469 | "_enabled": true,
470 | "__prefab": null,
471 | "outlineColor": "0xffffff",
472 | "outlineSize": 5,
473 | "_id": "5fcvjCEmpF9IfGakiOVRdQ"
474 | },
475 | {
476 | "__type__": "cc.UIOpacity",
477 | "_name": "",
478 | "_objFlags": 0,
479 | "node": {
480 | "__id__": 12
481 | },
482 | "_enabled": true,
483 | "__prefab": null,
484 | "_opacity": 255,
485 | "_id": "96tCYYbEtLE7niSnwk4nZ6"
486 | },
487 | {
488 | "__type__": "cc.UITransform",
489 | "_name": "",
490 | "_objFlags": 0,
491 | "node": {
492 | "__id__": 12
493 | },
494 | "_enabled": true,
495 | "__prefab": null,
496 | "_contentSize": {
497 | "__type__": "cc.Size",
498 | "width": 300,
499 | "height": 200
500 | },
501 | "_anchorPoint": {
502 | "__type__": "cc.Vec2",
503 | "x": 0.5,
504 | "y": 0.5
505 | },
506 | "_id": "83exZFvBxKEYNFErvw3Jnk"
507 | },
508 | {
509 | "__type__": "cc.Canvas",
510 | "_name": "",
511 | "_objFlags": 0,
512 | "node": {
513 | "__id__": 2
514 | },
515 | "_enabled": true,
516 | "__prefab": null,
517 | "_cameraComponent": {
518 | "__id__": 4
519 | },
520 | "_alignCanvasWithScreen": true,
521 | "_id": "27hFDZANZCb45Zgm4KlZTN"
522 | },
523 | {
524 | "__type__": "cc.Widget",
525 | "_name": "",
526 | "_objFlags": 0,
527 | "node": {
528 | "__id__": 2
529 | },
530 | "_enabled": true,
531 | "__prefab": null,
532 | "_alignFlags": 45,
533 | "_target": null,
534 | "_left": 0,
535 | "_right": 0,
536 | "_top": 0,
537 | "_bottom": 0,
538 | "_horizontalCenter": 0,
539 | "_verticalCenter": 0,
540 | "_isAbsLeft": true,
541 | "_isAbsRight": true,
542 | "_isAbsTop": true,
543 | "_isAbsBottom": true,
544 | "_isAbsHorizontalCenter": true,
545 | "_isAbsVerticalCenter": true,
546 | "_originalWidth": 0,
547 | "_originalHeight": 0,
548 | "_alignMode": 2,
549 | "_lockFlags": 0,
550 | "_id": "07LPE1IkxCz46Xr08zcdGR"
551 | },
552 | {
553 | "__type__": "cc.UIOpacity",
554 | "_name": "",
555 | "_objFlags": 0,
556 | "node": {
557 | "__id__": 2
558 | },
559 | "_enabled": true,
560 | "__prefab": null,
561 | "_opacity": 255,
562 | "_id": "98nm5uJ7xONayV30ijHdjz"
563 | },
564 | {
565 | "__type__": "cc.UITransform",
566 | "_name": "",
567 | "_objFlags": 0,
568 | "node": {
569 | "__id__": 2
570 | },
571 | "_enabled": true,
572 | "__prefab": null,
573 | "_contentSize": {
574 | "__type__": "cc.Size",
575 | "width": 960,
576 | "height": 640
577 | },
578 | "_anchorPoint": {
579 | "__type__": "cc.Vec2",
580 | "x": 0.5,
581 | "y": 0.5
582 | },
583 | "_id": "f0Uad3WMxAf4Y18YGrEbPS"
584 | },
585 | {
586 | "__type__": "cc.PrefabInfo",
587 | "fileId": "35aafe0d-9c5c-4287-b97b-add9203ff4a5"
588 | },
589 | {
590 | "__type__": "cc.SceneGlobals",
591 | "ambient": {
592 | "__id__": 23
593 | },
594 | "shadows": {
595 | "__id__": 24
596 | },
597 | "_skybox": {
598 | "__id__": 25
599 | },
600 | "fog": {
601 | "__id__": 26
602 | },
603 | "octree": {
604 | "__id__": 27
605 | }
606 | },
607 | {
608 | "__type__": "cc.AmbientInfo",
609 | "_skyColorHDR": {
610 | "__type__": "cc.Vec4",
611 | "x": 0.2,
612 | "y": 0.5019607843137255,
613 | "z": 0.8,
614 | "w": 0.520833125
615 | },
616 | "_skyColor": {
617 | "__type__": "cc.Vec4",
618 | "x": 0.2,
619 | "y": 0.5019607843137255,
620 | "z": 0.8,
621 | "w": 0.520833125
622 | },
623 | "_skyIllumHDR": 20000,
624 | "_skyIllum": 20000,
625 | "_groundAlbedoHDR": {
626 | "__type__": "cc.Vec4",
627 | "x": 0.2,
628 | "y": 0.2,
629 | "z": 0.2,
630 | "w": 1
631 | },
632 | "_groundAlbedo": {
633 | "__type__": "cc.Vec4",
634 | "x": 0.2,
635 | "y": 0.2,
636 | "z": 0.2,
637 | "w": 1
638 | },
639 | "_skyColorLDR": {
640 | "__type__": "cc.Vec4",
641 | "x": 0.2,
642 | "y": 0.5019607843137255,
643 | "z": 0.8,
644 | "w": 0.520833125
645 | },
646 | "_skyIllumLDR": 0.78125,
647 | "_groundAlbedoLDR": {
648 | "__type__": "cc.Vec4",
649 | "x": 0.2,
650 | "y": 0.2,
651 | "z": 0.2,
652 | "w": 1
653 | }
654 | },
655 | {
656 | "__type__": "cc.ShadowsInfo",
657 | "_enabled": false,
658 | "_type": 0,
659 | "_normal": {
660 | "__type__": "cc.Vec3",
661 | "x": 0,
662 | "y": 1,
663 | "z": 0
664 | },
665 | "_distance": 0,
666 | "_shadowColor": {
667 | "__type__": "cc.Color",
668 | "r": 0,
669 | "g": 0,
670 | "b": 0,
671 | "a": 76
672 | },
673 | "_maxReceived": 4,
674 | "_size": {
675 | "__type__": "cc.Vec2",
676 | "x": 512,
677 | "y": 512
678 | }
679 | },
680 | {
681 | "__type__": "cc.SkyboxInfo",
682 | "_envLightingType": 0,
683 | "_envmapHDR": null,
684 | "_envmap": null,
685 | "_envmapLDR": null,
686 | "_diffuseMapHDR": null,
687 | "_diffuseMapLDR": null,
688 | "_enabled": false,
689 | "_useHDR": true,
690 | "_editableMaterial": null,
691 | "_reflectionHDR": null,
692 | "_reflectionLDR": null
693 | },
694 | {
695 | "__type__": "cc.FogInfo",
696 | "_type": 0,
697 | "_fogColor": {
698 | "__type__": "cc.Color",
699 | "r": 225,
700 | "g": 225,
701 | "b": 225,
702 | "a": 255
703 | },
704 | "_enabled": false,
705 | "_fogDensity": 0.3,
706 | "_fogStart": 0.5,
707 | "_fogEnd": 300,
708 | "_fogAtten": 5,
709 | "_fogTop": 1.5,
710 | "_fogRange": 1.2,
711 | "_accurate": false
712 | },
713 | {
714 | "__type__": "cc.OctreeInfo",
715 | "_enabled": false,
716 | "_minPos": {
717 | "__type__": "cc.Vec3",
718 | "x": -1024,
719 | "y": -1024,
720 | "z": -1024
721 | },
722 | "_maxPos": {
723 | "__type__": "cc.Vec3",
724 | "x": 1024,
725 | "y": 1024,
726 | "z": 1024
727 | },
728 | "_depth": 8
729 | }
730 | ]
--------------------------------------------------------------------------------
/assets/case/01_spirteOutline/spirteOutline.scene.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.39",
3 | "importer": "scene",
4 | "imported": true,
5 | "uuid": "35aafe0d-9c5c-4287-b97b-add9203ff4a5",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/01_spirteOutline/spirteOutline.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: yansixing
3 | * @Date: 2019-07-30 08:22:32
4 | * @Github: https://github.com/yansixing
5 | * @LastEditTime: 2021-05-17 20:02:34
6 | */
7 |
8 | import { _decorator, Component, Sprite, Material, Vec4 } from 'cc';
9 | const { ccclass, property, executeInEditMode } = _decorator;
10 |
11 | import { Utils } from "../../utils/utils";
12 |
13 | @ccclass('SpirteOutline')
14 | @executeInEditMode
15 | export default class SpirteOutline extends Component {
16 | @property
17 | outlineColor: string = "0xffffff";
18 | @property
19 | outlineSize: number = 2;
20 | img: Sprite | null = null;
21 | material: Material | null = null;
22 | onLoad() {
23 | this.img = this.getComponent(Sprite);
24 | console.log(this.img?.sharedMaterial);
25 | // # outlineColor: { value: [1.0, 1.0, 1.0, 1.0], editor: { type: color } }
26 | // # textureSize: { value: [300.0, 200.0] }
27 | // # outlineSize: { value: 5.0 }
28 | // this.material =
29 | // this.img?.sharedMaterial?.setProperty('outlineSize', 20);
30 |
31 | //let { b, g, r } = Utils.hexToRGB(parseInt(this.outlineColor, 16));
32 | // outlineColor
33 | //this.material.effect.setProperty('outlineColor', new cc.Vec3(r / 255, g / 255, b / 255));
34 | // textureSize
35 | //this.material.effect.setProperty('textureSize', new cc.Vec2(this.img.node.width, this.img.node.height));
36 | // outlineSize
37 | //this.material.effect.setProperty('outlineSize', this.outlineSize);
38 | //console.log(this.material);
39 | }
40 | }
--------------------------------------------------------------------------------
/assets/case/01_spirteOutline/spirteOutline.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "4.0.23",
3 | "importer": "typescript",
4 | "imported": true,
5 | "uuid": "c50249ca-6b31-4c4a-837a-19382c1dd90e",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "simulateGlobals": []
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/02_blur.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.0",
3 | "importer": "directory",
4 | "imported": true,
5 | "uuid": "eed3f0a1-0d1e-439c-bd44-daee457be958",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "compressionType": {},
10 | "isRemoteBundle": {}
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/assets/case/02_blur/blur.effect:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
2 | CCEffect %{
3 | techniques:
4 | - passes:
5 | - vert: sprite-vs:vert
6 | frag: sprite-fs:frag
7 | depthStencilState:
8 | depthTest: false
9 | depthWrite: false
10 | blendState:
11 | targets:
12 | - blend: true
13 | blendSrc: src_alpha
14 | blendDst: one_minus_src_alpha
15 | blendDstAlpha: one_minus_src_alpha
16 | rasterizerState:
17 | cullMode: none
18 | properties:
19 | alphaThreshold: { value: 0.5 }
20 | resolution: { value: [384.0, 216.0] }
21 | }%
22 |
23 | CCProgram sprite-vs %{
24 | precision highp float;
25 | #include
26 | #if USE_LOCAL
27 | #include
28 | #endif
29 |
30 | in vec3 a_position;
31 | in vec2 a_texCoord;
32 | in vec4 a_color;
33 |
34 | out vec4 color;
35 | out vec2 uv0;
36 |
37 | vec4 vert () {
38 | vec4 pos = vec4(a_position, 1);
39 |
40 | #if USE_LOCAL
41 | pos = cc_matWorld * pos;
42 | #endif
43 |
44 | #if USE_PIXEL_ALIGNMENT
45 | pos = cc_matView * pos;
46 | pos.xyz = floor(pos.xyz);
47 | pos = cc_matProj * pos;
48 | #else
49 | pos = cc_matViewProj * pos;
50 | #endif
51 |
52 | uv0 = a_texCoord;
53 |
54 | color = a_color;
55 |
56 | return pos;
57 | }
58 | }%
59 |
60 | CCProgram sprite-fs %{
61 | precision highp float;
62 | #include
63 | #include
64 |
65 | in vec4 color;
66 |
67 | #if USE_TEXTURE
68 | in vec2 uv0;
69 | #pragma builtin(local)
70 | layout(set = 2, binding = 10) uniform sampler2D cc_spriteTexture;
71 | #endif
72 |
73 | uniform FragConstants {
74 | vec2 resolution;
75 | };
76 |
77 | const float blurRadius = 5.0;//半径
78 | const float sampleNum = 4.0;//间隔的段数
79 | vec4 blur(vec2);
80 |
81 | vec4 frag () {
82 | vec4 o = vec4(1, 1, 1, 1);
83 |
84 | #if USE_TEXTURE
85 | o *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0);
86 | #endif
87 |
88 | ALPHA_TEST(o);
89 | o = blur(uv0);
90 | o *= color;
91 | return o;
92 | }
93 |
94 | vec4 blur(vec2 p) {
95 | if (blurRadius > 0.0 && sampleNum > 1.0) {
96 | vec4 col = vec4(0.0);
97 | vec2 unit = 1.0 / resolution.xy;//单位坐标
98 | float count = 0.0;
99 | // 遍历一个矩形,当前的坐标为中心点,遍历矩形中每个像素点的颜色
100 | for (float x = -blurRadius; x < blurRadius; x += blurRadius / sampleNum) {
101 | for (float y = -blurRadius; y < blurRadius; y += blurRadius / sampleNum) {
102 | float weight = (blurRadius - abs(x)) * (blurRadius - abs(y));//权重,p点的权重最高,向四周依次减少
103 | col += CCSampleWithAlphaSeparated(cc_spriteTexture, p + vec2(x * unit.x, y * unit.y)) * weight;
104 | count += weight;
105 | }
106 | }
107 | //得到实际模糊颜色的值
108 | return col / count;
109 | }
110 | return CCSampleWithAlphaSeparated(cc_spriteTexture, p);
111 | }
112 | }%
113 |
--------------------------------------------------------------------------------
/assets/case/02_blur/blur.effect.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.5.9",
3 | "importer": "effect",
4 | "imported": true,
5 | "uuid": "02afaa38-d020-4fba-a00a-588f6693bd9f",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/02_blur/blur.mtl:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.Material",
3 | "_name": "",
4 | "_objFlags": 0,
5 | "_native": "",
6 | "_effectAsset": {
7 | "__uuid__": "02afaa38-d020-4fba-a00a-588f6693bd9f"
8 | },
9 | "_techIdx": 0,
10 | "_defines": [
11 | {
12 | "USE_TEXTURE": true
13 | }
14 | ],
15 | "_states": [
16 | {
17 | "rasterizerState": {},
18 | "depthStencilState": {},
19 | "blendState": {
20 | "targets": [
21 | {}
22 | ]
23 | }
24 | }
25 | ],
26 | "_props": [
27 | {}
28 | ]
29 | }
--------------------------------------------------------------------------------
/assets/case/02_blur/blur.mtl.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.13",
3 | "importer": "material",
4 | "imported": true,
5 | "uuid": "55009da1-3fa8-44ed-bc99-a2057dbf89ef",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/02_blur/blur.scene:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.SceneAsset",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "scene": {
8 | "__id__": 1
9 | }
10 | },
11 | {
12 | "__type__": "cc.Scene",
13 | "_name": "blur",
14 | "_objFlags": 0,
15 | "_parent": null,
16 | "_children": [
17 | {
18 | "__id__": 2
19 | }
20 | ],
21 | "_active": true,
22 | "_components": [],
23 | "_prefab": {
24 | "__id__": 29
25 | },
26 | "autoReleaseAssets": false,
27 | "_globals": {
28 | "__id__": 30
29 | },
30 | "_id": "112a59f9-a8ad-4847-a364-4d1e3e869f9e"
31 | },
32 | {
33 | "__type__": "cc.Node",
34 | "_name": "Canvas",
35 | "_objFlags": 0,
36 | "_parent": {
37 | "__id__": 1
38 | },
39 | "_children": [
40 | {
41 | "__id__": 3
42 | },
43 | {
44 | "__id__": 7
45 | },
46 | {
47 | "__id__": 12
48 | }
49 | ],
50 | "_active": true,
51 | "_components": [
52 | {
53 | "__id__": 25
54 | },
55 | {
56 | "__id__": 26
57 | },
58 | {
59 | "__id__": 27
60 | },
61 | {
62 | "__id__": 28
63 | }
64 | ],
65 | "_prefab": null,
66 | "_lpos": {
67 | "__type__": "cc.Vec3",
68 | "x": 480,
69 | "y": 320,
70 | "z": 0
71 | },
72 | "_lrot": {
73 | "__type__": "cc.Quat",
74 | "x": 0,
75 | "y": 0,
76 | "z": 0,
77 | "w": 1
78 | },
79 | "_lscale": {
80 | "__type__": "cc.Vec3",
81 | "x": 1,
82 | "y": 1,
83 | "z": 1
84 | },
85 | "_layer": 1,
86 | "_euler": {
87 | "__type__": "cc.Vec3",
88 | "x": 0,
89 | "y": 0,
90 | "z": 0
91 | },
92 | "_id": "d6Ngmh6ZRGFJLRuR75koHM"
93 | },
94 | {
95 | "__type__": "cc.Node",
96 | "_name": "Main Camera",
97 | "_objFlags": 0,
98 | "_parent": {
99 | "__id__": 2
100 | },
101 | "_children": [],
102 | "_active": true,
103 | "_components": [
104 | {
105 | "__id__": 4
106 | },
107 | {
108 | "__id__": 5
109 | },
110 | {
111 | "__id__": 6
112 | }
113 | ],
114 | "_prefab": null,
115 | "_lpos": {
116 | "__type__": "cc.Vec3",
117 | "x": 0,
118 | "y": 0,
119 | "z": 1000
120 | },
121 | "_lrot": {
122 | "__type__": "cc.Quat",
123 | "x": 0,
124 | "y": 0,
125 | "z": 0,
126 | "w": 1
127 | },
128 | "_lscale": {
129 | "__type__": "cc.Vec3",
130 | "x": 1,
131 | "y": 1,
132 | "z": 1
133 | },
134 | "_layer": 1,
135 | "_euler": {
136 | "__type__": "cc.Vec3",
137 | "x": 0,
138 | "y": 0,
139 | "z": 0
140 | },
141 | "_id": "famfQa9lNNDpy1laptVx12"
142 | },
143 | {
144 | "__type__": "cc.Camera",
145 | "_name": "",
146 | "_objFlags": 0,
147 | "node": {
148 | "__id__": 3
149 | },
150 | "_enabled": true,
151 | "__prefab": null,
152 | "_projection": 0,
153 | "_priority": -1,
154 | "_fov": 60,
155 | "_fovAxis": 0,
156 | "_orthoHeight": 426.31989596879066,
157 | "_near": 1,
158 | "_far": 4096,
159 | "_color": {
160 | "__type__": "cc.Color",
161 | "r": 0,
162 | "g": 0,
163 | "b": 0,
164 | "a": 255
165 | },
166 | "_depth": 1,
167 | "_stencil": 0,
168 | "_clearFlags": 7,
169 | "_rect": {
170 | "__type__": "cc.Rect",
171 | "x": 0,
172 | "y": 0,
173 | "width": 1,
174 | "height": 1
175 | },
176 | "_aperture": 19,
177 | "_shutter": 7,
178 | "_iso": 0,
179 | "_screenScale": 1,
180 | "_visibility": 4294967295,
181 | "_targetTexture": null,
182 | "_id": "12FxhQCQhKjLi1OSAfGzBd"
183 | },
184 | {
185 | "__type__": "cc.UIOpacity",
186 | "_name": "",
187 | "_objFlags": 0,
188 | "node": {
189 | "__id__": 3
190 | },
191 | "_enabled": true,
192 | "__prefab": null,
193 | "_opacity": 255,
194 | "_id": "09zIYuSb5InqrKwk4vlrM8"
195 | },
196 | {
197 | "__type__": "cc.UITransform",
198 | "_name": "",
199 | "_objFlags": 0,
200 | "node": {
201 | "__id__": 3
202 | },
203 | "_enabled": true,
204 | "__prefab": null,
205 | "_contentSize": {
206 | "__type__": "cc.Size",
207 | "width": 0,
208 | "height": 0
209 | },
210 | "_anchorPoint": {
211 | "__type__": "cc.Vec2",
212 | "x": 0.5,
213 | "y": 0.5
214 | },
215 | "_id": "feUtB9XvlP9qYe7H+nxQ0S"
216 | },
217 | {
218 | "__type__": "cc.Node",
219 | "_name": "bg",
220 | "_objFlags": 0,
221 | "_parent": {
222 | "__id__": 2
223 | },
224 | "_children": [],
225 | "_active": true,
226 | "_components": [
227 | {
228 | "__id__": 8
229 | },
230 | {
231 | "__id__": 9
232 | },
233 | {
234 | "__id__": 10
235 | },
236 | {
237 | "__id__": 11
238 | }
239 | ],
240 | "_prefab": null,
241 | "_lpos": {
242 | "__type__": "cc.Vec3",
243 | "x": 0,
244 | "y": 0,
245 | "z": 0
246 | },
247 | "_lrot": {
248 | "__type__": "cc.Quat",
249 | "x": 0,
250 | "y": 0,
251 | "z": 0,
252 | "w": 1
253 | },
254 | "_lscale": {
255 | "__type__": "cc.Vec3",
256 | "x": 1,
257 | "y": 1,
258 | "z": 1
259 | },
260 | "_layer": 1,
261 | "_euler": {
262 | "__type__": "cc.Vec3",
263 | "x": 0,
264 | "y": 0,
265 | "z": 0
266 | },
267 | "_id": "2fUVfrgY9NRrX+cio35bw9"
268 | },
269 | {
270 | "__type__": "cc.Sprite",
271 | "_name": "",
272 | "_objFlags": 0,
273 | "node": {
274 | "__id__": 7
275 | },
276 | "_enabled": true,
277 | "__prefab": null,
278 | "_customMaterial": {
279 | "__uuid__": "fda095cb-831d-4601-ad94-846013963de8",
280 | "__expectedType__": "cc.Material"
281 | },
282 | "_srcBlendFactor": 2,
283 | "_dstBlendFactor": 4,
284 | "_color": {
285 | "__type__": "cc.Color",
286 | "r": 197,
287 | "g": 197,
288 | "b": 197,
289 | "a": 255
290 | },
291 | "_spriteFrame": {
292 | "__uuid__": "7d8f9b89-4fd1-4c9f-a3ab-38ec7cded7ca@f9941",
293 | "__expectedType__": "cc.SpriteFrame"
294 | },
295 | "_type": 0,
296 | "_fillType": 0,
297 | "_sizeMode": 0,
298 | "_fillCenter": {
299 | "__type__": "cc.Vec2",
300 | "x": 0,
301 | "y": 0
302 | },
303 | "_fillStart": 0,
304 | "_fillRange": 0,
305 | "_isTrimmedMode": false,
306 | "_useGrayscale": false,
307 | "_atlas": null,
308 | "_id": "61LUH7tyhDp4a/rKjWDA4V"
309 | },
310 | {
311 | "__type__": "cc.Widget",
312 | "_name": "",
313 | "_objFlags": 0,
314 | "node": {
315 | "__id__": 7
316 | },
317 | "_enabled": true,
318 | "__prefab": null,
319 | "_alignFlags": 45,
320 | "_target": null,
321 | "_left": 0,
322 | "_right": 0,
323 | "_top": 0,
324 | "_bottom": 0,
325 | "_horizontalCenter": 0,
326 | "_verticalCenter": 0,
327 | "_isAbsLeft": true,
328 | "_isAbsRight": true,
329 | "_isAbsTop": true,
330 | "_isAbsBottom": true,
331 | "_isAbsHorizontalCenter": true,
332 | "_isAbsVerticalCenter": true,
333 | "_originalWidth": 100,
334 | "_originalHeight": 100,
335 | "_alignMode": 2,
336 | "_lockFlags": 0,
337 | "_id": "58V7iCpjZLb7A5Z9/SI9eo"
338 | },
339 | {
340 | "__type__": "cc.UIOpacity",
341 | "_name": "",
342 | "_objFlags": 0,
343 | "node": {
344 | "__id__": 7
345 | },
346 | "_enabled": true,
347 | "__prefab": null,
348 | "_opacity": 255,
349 | "_id": "81xtPv9rtGZ4xRskG6jMRO"
350 | },
351 | {
352 | "__type__": "cc.UITransform",
353 | "_name": "",
354 | "_objFlags": 0,
355 | "node": {
356 | "__id__": 7
357 | },
358 | "_enabled": true,
359 | "__prefab": null,
360 | "_contentSize": {
361 | "__type__": "cc.Size",
362 | "width": 960,
363 | "height": 640
364 | },
365 | "_anchorPoint": {
366 | "__type__": "cc.Vec2",
367 | "x": 0.5,
368 | "y": 0.5
369 | },
370 | "_id": "b4Z9xF1pBEeLmPrt9TmrCU"
371 | },
372 | {
373 | "__type__": "cc.Node",
374 | "_name": "container",
375 | "_objFlags": 0,
376 | "_parent": {
377 | "__id__": 2
378 | },
379 | "_children": [
380 | {
381 | "__id__": 13
382 | },
383 | {
384 | "__id__": 18
385 | }
386 | ],
387 | "_active": true,
388 | "_components": [
389 | {
390 | "__id__": 22
391 | },
392 | {
393 | "__id__": 23
394 | },
395 | {
396 | "__id__": 24
397 | }
398 | ],
399 | "_prefab": null,
400 | "_lpos": {
401 | "__type__": "cc.Vec3",
402 | "x": 0,
403 | "y": 0,
404 | "z": 0
405 | },
406 | "_lrot": {
407 | "__type__": "cc.Quat",
408 | "x": 0,
409 | "y": 0,
410 | "z": 0,
411 | "w": 1
412 | },
413 | "_lscale": {
414 | "__type__": "cc.Vec3",
415 | "x": 1,
416 | "y": 1,
417 | "z": 1
418 | },
419 | "_layer": 1,
420 | "_euler": {
421 | "__type__": "cc.Vec3",
422 | "x": 0,
423 | "y": 0,
424 | "z": 0
425 | },
426 | "_id": "a74uHAikdA7Ix5PnPvCULy"
427 | },
428 | {
429 | "__type__": "cc.Node",
430 | "_name": "img_fort",
431 | "_objFlags": 0,
432 | "_parent": {
433 | "__id__": 12
434 | },
435 | "_children": [],
436 | "_active": true,
437 | "_components": [
438 | {
439 | "__id__": 14
440 | },
441 | {
442 | "__id__": 15
443 | },
444 | {
445 | "__id__": 16
446 | },
447 | {
448 | "__id__": 17
449 | }
450 | ],
451 | "_prefab": null,
452 | "_lpos": {
453 | "__type__": "cc.Vec3",
454 | "x": 0,
455 | "y": 108,
456 | "z": 0
457 | },
458 | "_lrot": {
459 | "__type__": "cc.Quat",
460 | "x": 0,
461 | "y": 0,
462 | "z": 0,
463 | "w": 1
464 | },
465 | "_lscale": {
466 | "__type__": "cc.Vec3",
467 | "x": 1,
468 | "y": 1,
469 | "z": 1
470 | },
471 | "_layer": 1,
472 | "_euler": {
473 | "__type__": "cc.Vec3",
474 | "x": 0,
475 | "y": 0,
476 | "z": 0
477 | },
478 | "_id": "56HYDPtjRMgoZVxF733D5Y"
479 | },
480 | {
481 | "__type__": "cc.Sprite",
482 | "_name": "",
483 | "_objFlags": 0,
484 | "node": {
485 | "__id__": 13
486 | },
487 | "_enabled": true,
488 | "__prefab": null,
489 | "_customMaterial": {
490 | "__uuid__": "55009da1-3fa8-44ed-bc99-a2057dbf89ef",
491 | "__expectedType__": "cc.Material"
492 | },
493 | "_srcBlendFactor": 2,
494 | "_dstBlendFactor": 4,
495 | "_color": {
496 | "__type__": "cc.Color",
497 | "r": 255,
498 | "g": 255,
499 | "b": 255,
500 | "a": 255
501 | },
502 | "_spriteFrame": {
503 | "__uuid__": "530d0a9f-ee1a-4b85-b306-7b50bf6d5ab5@f9941",
504 | "__expectedType__": "cc.SpriteFrame"
505 | },
506 | "_type": 0,
507 | "_fillType": 0,
508 | "_sizeMode": 0,
509 | "_fillCenter": {
510 | "__type__": "cc.Vec2",
511 | "x": 0,
512 | "y": 0
513 | },
514 | "_fillStart": 0,
515 | "_fillRange": 0,
516 | "_isTrimmedMode": false,
517 | "_useGrayscale": false,
518 | "_atlas": null,
519 | "_id": "0avbX6WYtCQIPhcpBZwtNg"
520 | },
521 | {
522 | "__type__": "1c6ff0Zg/lMlKoU6vpUNW/v",
523 | "_name": "",
524 | "_objFlags": 0,
525 | "node": {
526 | "__id__": 13
527 | },
528 | "_enabled": true,
529 | "__prefab": null,
530 | "_id": "5dZRXwoPpGD499Ue/G7gTM"
531 | },
532 | {
533 | "__type__": "cc.UIOpacity",
534 | "_name": "",
535 | "_objFlags": 0,
536 | "node": {
537 | "__id__": 13
538 | },
539 | "_enabled": true,
540 | "__prefab": null,
541 | "_opacity": 255,
542 | "_id": "0c3twfw89KZooS7dOZeUUp"
543 | },
544 | {
545 | "__type__": "cc.UITransform",
546 | "_name": "",
547 | "_objFlags": 0,
548 | "node": {
549 | "__id__": 13
550 | },
551 | "_enabled": true,
552 | "__prefab": null,
553 | "_contentSize": {
554 | "__type__": "cc.Size",
555 | "width": 384,
556 | "height": 216
557 | },
558 | "_anchorPoint": {
559 | "__type__": "cc.Vec2",
560 | "x": 0.5,
561 | "y": 0.5
562 | },
563 | "_id": "c1yoW2n0xAw6t3LhPRgW1O"
564 | },
565 | {
566 | "__type__": "cc.Node",
567 | "_name": "img_fort",
568 | "_objFlags": 0,
569 | "_parent": {
570 | "__id__": 12
571 | },
572 | "_children": [],
573 | "_active": true,
574 | "_components": [
575 | {
576 | "__id__": 19
577 | },
578 | {
579 | "__id__": 20
580 | },
581 | {
582 | "__id__": 21
583 | }
584 | ],
585 | "_prefab": null,
586 | "_lpos": {
587 | "__type__": "cc.Vec3",
588 | "x": 0,
589 | "y": -108,
590 | "z": 0
591 | },
592 | "_lrot": {
593 | "__type__": "cc.Quat",
594 | "x": 0,
595 | "y": 0,
596 | "z": 0,
597 | "w": 1
598 | },
599 | "_lscale": {
600 | "__type__": "cc.Vec3",
601 | "x": 1,
602 | "y": 1,
603 | "z": 1
604 | },
605 | "_layer": 1,
606 | "_euler": {
607 | "__type__": "cc.Vec3",
608 | "x": 0,
609 | "y": 0,
610 | "z": 0
611 | },
612 | "_id": "57IynrYRREObXc65h3bEQp"
613 | },
614 | {
615 | "__type__": "cc.Sprite",
616 | "_name": "",
617 | "_objFlags": 0,
618 | "node": {
619 | "__id__": 18
620 | },
621 | "_enabled": true,
622 | "__prefab": null,
623 | "_customMaterial": {
624 | "__uuid__": "fda095cb-831d-4601-ad94-846013963de8",
625 | "__expectedType__": "cc.Material"
626 | },
627 | "_srcBlendFactor": 2,
628 | "_dstBlendFactor": 4,
629 | "_color": {
630 | "__type__": "cc.Color",
631 | "r": 255,
632 | "g": 255,
633 | "b": 255,
634 | "a": 255
635 | },
636 | "_spriteFrame": {
637 | "__uuid__": "530d0a9f-ee1a-4b85-b306-7b50bf6d5ab5@f9941",
638 | "__expectedType__": "cc.SpriteFrame"
639 | },
640 | "_type": 0,
641 | "_fillType": 0,
642 | "_sizeMode": 0,
643 | "_fillCenter": {
644 | "__type__": "cc.Vec2",
645 | "x": 0,
646 | "y": 0
647 | },
648 | "_fillStart": 0,
649 | "_fillRange": 0,
650 | "_isTrimmedMode": false,
651 | "_useGrayscale": false,
652 | "_atlas": null,
653 | "_id": "32dxBNRb5I2pdalPCqd+gf"
654 | },
655 | {
656 | "__type__": "cc.UIOpacity",
657 | "_name": "",
658 | "_objFlags": 0,
659 | "node": {
660 | "__id__": 18
661 | },
662 | "_enabled": true,
663 | "__prefab": null,
664 | "_opacity": 255,
665 | "_id": "577oTfYnFJ7LlCiG4H5aBq"
666 | },
667 | {
668 | "__type__": "cc.UITransform",
669 | "_name": "",
670 | "_objFlags": 0,
671 | "node": {
672 | "__id__": 18
673 | },
674 | "_enabled": true,
675 | "__prefab": null,
676 | "_contentSize": {
677 | "__type__": "cc.Size",
678 | "width": 384,
679 | "height": 216
680 | },
681 | "_anchorPoint": {
682 | "__type__": "cc.Vec2",
683 | "x": 0.5,
684 | "y": 0.5
685 | },
686 | "_id": "491Oz+FXdOyopjGtLf2zPx"
687 | },
688 | {
689 | "__type__": "cc.Layout",
690 | "_name": "",
691 | "_objFlags": 0,
692 | "node": {
693 | "__id__": 12
694 | },
695 | "_enabled": true,
696 | "__prefab": null,
697 | "_resizeMode": 0,
698 | "_layoutType": 2,
699 | "_cellSize": {
700 | "__type__": "cc.Size",
701 | "width": 40,
702 | "height": 40
703 | },
704 | "_startAxis": 0,
705 | "_paddingLeft": 0,
706 | "_paddingRight": 0,
707 | "_paddingTop": 0,
708 | "_paddingBottom": 0,
709 | "_spacingX": 0,
710 | "_spacingY": 0,
711 | "_verticalDirection": 1,
712 | "_horizontalDirection": 0,
713 | "_constraint": 0,
714 | "_constraintNum": 2,
715 | "_affectedByScale": false,
716 | "_isAlign": true,
717 | "_id": "e6k2/0OFNGWqC9dctowTzs"
718 | },
719 | {
720 | "__type__": "cc.UIOpacity",
721 | "_name": "",
722 | "_objFlags": 0,
723 | "node": {
724 | "__id__": 12
725 | },
726 | "_enabled": true,
727 | "__prefab": null,
728 | "_opacity": 255,
729 | "_id": "47hCGSP1lL9IT2GqTUGIC0"
730 | },
731 | {
732 | "__type__": "cc.UITransform",
733 | "_name": "",
734 | "_objFlags": 0,
735 | "node": {
736 | "__id__": 12
737 | },
738 | "_enabled": true,
739 | "__prefab": null,
740 | "_contentSize": {
741 | "__type__": "cc.Size",
742 | "width": 384,
743 | "height": 432
744 | },
745 | "_anchorPoint": {
746 | "__type__": "cc.Vec2",
747 | "x": 0.5,
748 | "y": 0.5
749 | },
750 | "_id": "11CTKCA0JG+KOm6XBr4B2e"
751 | },
752 | {
753 | "__type__": "cc.Canvas",
754 | "_name": "",
755 | "_objFlags": 0,
756 | "node": {
757 | "__id__": 2
758 | },
759 | "_enabled": true,
760 | "__prefab": null,
761 | "_cameraComponent": {
762 | "__id__": 4
763 | },
764 | "_alignCanvasWithScreen": true,
765 | "_id": "27hFDZANZCb45Zgm4KlZTN"
766 | },
767 | {
768 | "__type__": "cc.Widget",
769 | "_name": "",
770 | "_objFlags": 0,
771 | "node": {
772 | "__id__": 2
773 | },
774 | "_enabled": true,
775 | "__prefab": null,
776 | "_alignFlags": 45,
777 | "_target": null,
778 | "_left": 0,
779 | "_right": 0,
780 | "_top": 0,
781 | "_bottom": 0,
782 | "_horizontalCenter": 0,
783 | "_verticalCenter": 0,
784 | "_isAbsLeft": true,
785 | "_isAbsRight": true,
786 | "_isAbsTop": true,
787 | "_isAbsBottom": true,
788 | "_isAbsHorizontalCenter": true,
789 | "_isAbsVerticalCenter": true,
790 | "_originalWidth": 0,
791 | "_originalHeight": 0,
792 | "_alignMode": 2,
793 | "_lockFlags": 0,
794 | "_id": "ebAse80ZBHyJFX8Y1Gy1ax"
795 | },
796 | {
797 | "__type__": "cc.UIOpacity",
798 | "_name": "",
799 | "_objFlags": 0,
800 | "node": {
801 | "__id__": 2
802 | },
803 | "_enabled": true,
804 | "__prefab": null,
805 | "_opacity": 255,
806 | "_id": "3bwSEn4hhBIJDmaxtG2C41"
807 | },
808 | {
809 | "__type__": "cc.UITransform",
810 | "_name": "",
811 | "_objFlags": 0,
812 | "node": {
813 | "__id__": 2
814 | },
815 | "_enabled": true,
816 | "__prefab": null,
817 | "_contentSize": {
818 | "__type__": "cc.Size",
819 | "width": 960,
820 | "height": 640
821 | },
822 | "_anchorPoint": {
823 | "__type__": "cc.Vec2",
824 | "x": 0.5,
825 | "y": 0.5
826 | },
827 | "_id": "ebY32P+0tBBataSj0X490G"
828 | },
829 | {
830 | "__type__": "cc.PrefabInfo",
831 | "fileId": "112a59f9-a8ad-4847-a364-4d1e3e869f9e"
832 | },
833 | {
834 | "__type__": "cc.SceneGlobals",
835 | "ambient": {
836 | "__id__": 31
837 | },
838 | "shadows": {
839 | "__id__": 32
840 | },
841 | "_skybox": {
842 | "__id__": 33
843 | },
844 | "fog": {
845 | "__id__": 34
846 | },
847 | "octree": {
848 | "__id__": 35
849 | }
850 | },
851 | {
852 | "__type__": "cc.AmbientInfo",
853 | "_skyColorHDR": {
854 | "__type__": "cc.Vec4",
855 | "x": 0.2,
856 | "y": 0.5019607843137255,
857 | "z": 0.8,
858 | "w": 0.520833125
859 | },
860 | "_skyColor": {
861 | "__type__": "cc.Vec4",
862 | "x": 0.2,
863 | "y": 0.5019607843137255,
864 | "z": 0.8,
865 | "w": 0.520833125
866 | },
867 | "_skyIllumHDR": 20000,
868 | "_skyIllum": 20000,
869 | "_groundAlbedoHDR": {
870 | "__type__": "cc.Vec4",
871 | "x": 0.2,
872 | "y": 0.2,
873 | "z": 0.2,
874 | "w": 1
875 | },
876 | "_groundAlbedo": {
877 | "__type__": "cc.Vec4",
878 | "x": 0.2,
879 | "y": 0.2,
880 | "z": 0.2,
881 | "w": 1
882 | },
883 | "_skyColorLDR": {
884 | "__type__": "cc.Vec4",
885 | "x": 0.2,
886 | "y": 0.5019607843137255,
887 | "z": 0.8,
888 | "w": 0.520833125
889 | },
890 | "_skyIllumLDR": 0.78125,
891 | "_groundAlbedoLDR": {
892 | "__type__": "cc.Vec4",
893 | "x": 0.2,
894 | "y": 0.2,
895 | "z": 0.2,
896 | "w": 1
897 | }
898 | },
899 | {
900 | "__type__": "cc.ShadowsInfo",
901 | "_enabled": false,
902 | "_type": 0,
903 | "_normal": {
904 | "__type__": "cc.Vec3",
905 | "x": 0,
906 | "y": 1,
907 | "z": 0
908 | },
909 | "_distance": 0,
910 | "_shadowColor": {
911 | "__type__": "cc.Color",
912 | "r": 0,
913 | "g": 0,
914 | "b": 0,
915 | "a": 76
916 | },
917 | "_maxReceived": 4,
918 | "_size": {
919 | "__type__": "cc.Vec2",
920 | "x": 512,
921 | "y": 512
922 | }
923 | },
924 | {
925 | "__type__": "cc.SkyboxInfo",
926 | "_envLightingType": 0,
927 | "_envmapHDR": null,
928 | "_envmap": null,
929 | "_envmapLDR": null,
930 | "_diffuseMapHDR": null,
931 | "_diffuseMapLDR": null,
932 | "_enabled": false,
933 | "_useHDR": true,
934 | "_editableMaterial": null,
935 | "_reflectionHDR": null,
936 | "_reflectionLDR": null
937 | },
938 | {
939 | "__type__": "cc.FogInfo",
940 | "_type": 0,
941 | "_fogColor": {
942 | "__type__": "cc.Color",
943 | "r": 225,
944 | "g": 225,
945 | "b": 225,
946 | "a": 255
947 | },
948 | "_enabled": false,
949 | "_fogDensity": 0.3,
950 | "_fogStart": 0.5,
951 | "_fogEnd": 300,
952 | "_fogAtten": 5,
953 | "_fogTop": 1.5,
954 | "_fogRange": 1.2,
955 | "_accurate": false
956 | },
957 | {
958 | "__type__": "cc.OctreeInfo",
959 | "_enabled": false,
960 | "_minPos": {
961 | "__type__": "cc.Vec3",
962 | "x": -1024,
963 | "y": -1024,
964 | "z": -1024
965 | },
966 | "_maxPos": {
967 | "__type__": "cc.Vec3",
968 | "x": 1024,
969 | "y": 1024,
970 | "z": 1024
971 | },
972 | "_depth": 8
973 | }
974 | ]
--------------------------------------------------------------------------------
/assets/case/02_blur/blur.scene.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.39",
3 | "importer": "scene",
4 | "imported": true,
5 | "uuid": "112a59f9-a8ad-4847-a364-4d1e3e869f9e",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/02_blur/blur.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: yansixing
3 | * @Date: 2019-07-30 08:22:32
4 | * @Github: https://github.com/yansixing
5 | * @LastEditTime: 2021-05-17 20:01:01
6 | */
7 |
8 | import { _decorator, Component, Sprite, Material } from 'cc';
9 | const { ccclass, property,executeInEditMode } = _decorator;
10 |
11 | import { Utils } from "../../utils/utils";
12 |
13 | @ccclass('Blur')
14 | @executeInEditMode
15 | export default class Blur extends Component {
16 | // @property
17 | // enabled: boolean = true;
18 | // @property
19 | // outlineColor: string = "0xffffff";
20 | // @property
21 | // outlineSize: number = 2;
22 | img: Sprite | null = null;
23 | material: Material | null = null;
24 | onLoad() {
25 |
26 | this.img = this.getComponent(Sprite);
27 | console.log(this.img?.sharedMaterial);
28 |
29 | // resolution
30 | //this.material.effect.setProperty('resolution', new cc.Vec2(this.img.node.width, this.img.node.height));
31 | // // blurRadius
32 | // this.material.effect.setProperty('blurRadius', 5);
33 | // // sampleNum
34 | // this.material.effect.setProperty('sampleNum', 4);
35 | //console.log(this.material);
36 | }
37 | }
38 |
39 | /**
40 | * 注意:已把原脚本注释,由于脚本变动过大,转换的时候可能有遗落,需要自行手动转换
41 | */
42 | // /*
43 | // * @Author: yansixing
44 | // * @Date: 2019-07-30 08:22:32
45 | // * @Github: https://github.com/yansixing
46 | // * @LastEditTime: 2020-08-03 17:55:46
47 | // */
48 | // import { Utils } from "../../utils/utils";
49 | //
50 | // const { ccclass, property,executeInEditMode } = cc._decorator;
51 | //
52 | // @ccclass
53 | // @executeInEditMode
54 | // export default class Blur extends cc.Component {
55 | //
56 | // // @property
57 | // // enabled: boolean = true;
58 | // // @property
59 | // // outlineColor: string = "0xffffff";
60 | // // @property
61 | // // outlineSize: number = 2;
62 | //
63 | // img: cc.Sprite = null;
64 | // material: cc.Material;
65 | //
66 | // onLoad() {
67 | //
68 | // this.img = this.getComponent(cc.Sprite);
69 | // this.material = this.img.getMaterial(0);
70 | //
71 | // // resolution
72 | // this.material.effect.setProperty('resolution', new cc.Vec2(this.img.node.width, this.img.node.height));
73 | // // // blurRadius
74 | // // this.material.effect.setProperty('blurRadius', 5);
75 | // // // sampleNum
76 | // // this.material.effect.setProperty('sampleNum', 4);
77 | // console.log(this.material);
78 | // }
79 | //
80 | //
81 | //
82 | // }
83 |
--------------------------------------------------------------------------------
/assets/case/02_blur/blur.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "4.0.23",
3 | "importer": "typescript",
4 | "imported": true,
5 | "uuid": "1c6ffd19-83f9-4c94-aa14-eafa54356fef",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "simulateGlobals": []
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/03_flash.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.0",
3 | "importer": "directory",
4 | "imported": true,
5 | "uuid": "1ba1b210-d8ad-485e-a1e4-adf54f3ab33a",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "compressionType": {},
10 | "isRemoteBundle": {}
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/assets/case/03_flash/flash.effect:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
2 | CCEffect %{
3 | techniques:
4 | - passes:
5 | - vert: sprite-vs:vert
6 | frag: sprite-fs:frag
7 | depthStencilState:
8 | depthTest: false
9 | depthWrite: false
10 | blendState:
11 | targets:
12 | - blend: true
13 | blendSrc: src_alpha
14 | blendDst: one_minus_src_alpha
15 | blendDstAlpha: one_minus_src_alpha
16 | rasterizerState:
17 | cullMode: none
18 | properties:
19 | alphaThreshold: { value: 0.5 }
20 | time: { value: 0.0 }
21 | }%
22 |
23 | CCProgram sprite-vs %{
24 | precision highp float;
25 | #include
26 | #if USE_LOCAL
27 | #include
28 | #endif
29 |
30 | in vec3 a_position;
31 | in vec2 a_texCoord;
32 | in vec4 a_color;
33 |
34 | out vec4 color;
35 | out vec2 uv0;
36 |
37 | vec4 vert () {
38 | vec4 pos = vec4(a_position, 1);
39 |
40 | #if USE_LOCAL
41 | pos = cc_matWorld * pos;
42 | #endif
43 |
44 | #if USE_PIXEL_ALIGNMENT
45 | pos = cc_matView * pos;
46 | pos.xyz = floor(pos.xyz);
47 | pos = cc_matProj * pos;
48 | #else
49 | pos = cc_matViewProj * pos;
50 | #endif
51 |
52 | uv0 = a_texCoord;
53 |
54 | color = a_color;
55 |
56 | return pos;
57 | }
58 | }%
59 |
60 | CCProgram sprite-fs %{
61 | precision highp float;
62 | #include
63 | #include
64 |
65 | in vec4 color;
66 |
67 | #if USE_TEXTURE
68 | in vec2 uv0;
69 | #pragma builtin(local)
70 | layout(set = 2, binding = 10) uniform sampler2D cc_spriteTexture;
71 | #endif
72 |
73 | uniform FragConstants {
74 | float time;
75 | };
76 |
77 | vec4 frag () {
78 | vec4 o = vec4(1, 1, 1, 1);
79 |
80 | #if USE_TEXTURE
81 | o *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0);
82 | #endif
83 |
84 | float width = 0.1; //流光的宽度范围 (调整该值改变流光的宽度)
85 | float start = tan(time/1.0); //流光的起始x坐标
86 | float strength = 0.006; //流光增亮强度 (调整该值改变流光的增亮强度)
87 | float offset = 0.25; //偏移值 (调整该值改变流光的倾斜程度)
88 | if( uv0.x < (start - offset * uv0.y) && uv0.x > (start - offset * uv0.y - width))
89 | {
90 | vec3 improve = strength * vec3(255, 255, 255);
91 | vec3 result = improve * vec3( o.r, o.g, o.b);
92 | return vec4(result, o.a);
93 |
94 | }else{
95 | return o;
96 | }
97 |
98 | o *= color;
99 | ALPHA_TEST(o);
100 | return o;
101 | }
102 | }%
103 |
--------------------------------------------------------------------------------
/assets/case/03_flash/flash.effect.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.5.9",
3 | "importer": "effect",
4 | "imported": true,
5 | "uuid": "f0e6eb0c-d964-4e5a-8d7e-1b48e300220d",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/03_flash/flash.mtl:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.Material",
3 | "_name": "",
4 | "_objFlags": 0,
5 | "_native": "",
6 | "_effectAsset": {
7 | "__uuid__": "f0e6eb0c-d964-4e5a-8d7e-1b48e300220d"
8 | },
9 | "_techIdx": 0,
10 | "_defines": [
11 | {
12 | "USE_TEXTURE": true
13 | }
14 | ],
15 | "_states": [
16 | {
17 | "rasterizerState": {},
18 | "depthStencilState": {},
19 | "blendState": {
20 | "targets": [
21 | {}
22 | ]
23 | }
24 | }
25 | ],
26 | "_props": [
27 | {}
28 | ]
29 | }
--------------------------------------------------------------------------------
/assets/case/03_flash/flash.mtl.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.13",
3 | "importer": "material",
4 | "imported": true,
5 | "uuid": "a0911d08-f9e8-4119-99b9-62c07e890f5f",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/03_flash/flash.scene:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.SceneAsset",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "scene": {
8 | "__id__": 1
9 | }
10 | },
11 | {
12 | "__type__": "cc.Scene",
13 | "_name": "flash",
14 | "_objFlags": 0,
15 | "_parent": null,
16 | "_children": [
17 | {
18 | "__id__": 2
19 | }
20 | ],
21 | "_active": true,
22 | "_components": [],
23 | "_prefab": {
24 | "__id__": 29
25 | },
26 | "autoReleaseAssets": false,
27 | "_globals": {
28 | "__id__": 30
29 | },
30 | "_id": "cdb032e3-6bd3-449a-9f85-ad28907565d4"
31 | },
32 | {
33 | "__type__": "cc.Node",
34 | "_name": "Canvas",
35 | "_objFlags": 0,
36 | "_parent": {
37 | "__id__": 1
38 | },
39 | "_children": [
40 | {
41 | "__id__": 3
42 | },
43 | {
44 | "__id__": 7
45 | },
46 | {
47 | "__id__": 12
48 | }
49 | ],
50 | "_active": true,
51 | "_components": [
52 | {
53 | "__id__": 25
54 | },
55 | {
56 | "__id__": 26
57 | },
58 | {
59 | "__id__": 27
60 | },
61 | {
62 | "__id__": 28
63 | }
64 | ],
65 | "_prefab": null,
66 | "_lpos": {
67 | "__type__": "cc.Vec3",
68 | "x": 480,
69 | "y": 320,
70 | "z": 0
71 | },
72 | "_lrot": {
73 | "__type__": "cc.Quat",
74 | "x": 0,
75 | "y": 0,
76 | "z": 0,
77 | "w": 1
78 | },
79 | "_lscale": {
80 | "__type__": "cc.Vec3",
81 | "x": 1,
82 | "y": 1,
83 | "z": 1
84 | },
85 | "_layer": 1,
86 | "_euler": {
87 | "__type__": "cc.Vec3",
88 | "x": 0,
89 | "y": 0,
90 | "z": 0
91 | },
92 | "_id": "d6Ngmh6ZRGFJLRuR75koHM"
93 | },
94 | {
95 | "__type__": "cc.Node",
96 | "_name": "Main Camera",
97 | "_objFlags": 0,
98 | "_parent": {
99 | "__id__": 2
100 | },
101 | "_children": [],
102 | "_active": true,
103 | "_components": [
104 | {
105 | "__id__": 4
106 | },
107 | {
108 | "__id__": 5
109 | },
110 | {
111 | "__id__": 6
112 | }
113 | ],
114 | "_prefab": null,
115 | "_lpos": {
116 | "__type__": "cc.Vec3",
117 | "x": 0,
118 | "y": 0,
119 | "z": 1000
120 | },
121 | "_lrot": {
122 | "__type__": "cc.Quat",
123 | "x": 0,
124 | "y": 0,
125 | "z": 0,
126 | "w": 1
127 | },
128 | "_lscale": {
129 | "__type__": "cc.Vec3",
130 | "x": 1,
131 | "y": 1,
132 | "z": 1
133 | },
134 | "_layer": 1,
135 | "_euler": {
136 | "__type__": "cc.Vec3",
137 | "x": 0,
138 | "y": 0,
139 | "z": 0
140 | },
141 | "_id": "famfQa9lNNDpy1laptVx12"
142 | },
143 | {
144 | "__type__": "cc.Camera",
145 | "_name": "",
146 | "_objFlags": 0,
147 | "node": {
148 | "__id__": 3
149 | },
150 | "_enabled": true,
151 | "__prefab": null,
152 | "_projection": 0,
153 | "_priority": -1,
154 | "_fov": 60,
155 | "_fovAxis": 0,
156 | "_orthoHeight": 426.31989596879066,
157 | "_near": 1,
158 | "_far": 4096,
159 | "_color": {
160 | "__type__": "cc.Color",
161 | "r": 0,
162 | "g": 0,
163 | "b": 0,
164 | "a": 255
165 | },
166 | "_depth": 1,
167 | "_stencil": 0,
168 | "_clearFlags": 7,
169 | "_rect": {
170 | "__type__": "cc.Rect",
171 | "x": 0,
172 | "y": 0,
173 | "width": 1,
174 | "height": 1
175 | },
176 | "_aperture": 19,
177 | "_shutter": 7,
178 | "_iso": 0,
179 | "_screenScale": 1,
180 | "_visibility": 4294967295,
181 | "_targetTexture": null,
182 | "_id": "12FxhQCQhKjLi1OSAfGzBd"
183 | },
184 | {
185 | "__type__": "cc.UIOpacity",
186 | "_name": "",
187 | "_objFlags": 0,
188 | "node": {
189 | "__id__": 3
190 | },
191 | "_enabled": true,
192 | "__prefab": null,
193 | "_opacity": 255,
194 | "_id": "e1s+D4sWpGuLuhsilA461p"
195 | },
196 | {
197 | "__type__": "cc.UITransform",
198 | "_name": "",
199 | "_objFlags": 0,
200 | "node": {
201 | "__id__": 3
202 | },
203 | "_enabled": true,
204 | "__prefab": null,
205 | "_contentSize": {
206 | "__type__": "cc.Size",
207 | "width": 0,
208 | "height": 0
209 | },
210 | "_anchorPoint": {
211 | "__type__": "cc.Vec2",
212 | "x": 0.5,
213 | "y": 0.5
214 | },
215 | "_id": "76Pi+9y7hN778XSAxc+tii"
216 | },
217 | {
218 | "__type__": "cc.Node",
219 | "_name": "bg",
220 | "_objFlags": 0,
221 | "_parent": {
222 | "__id__": 2
223 | },
224 | "_children": [],
225 | "_active": true,
226 | "_components": [
227 | {
228 | "__id__": 8
229 | },
230 | {
231 | "__id__": 9
232 | },
233 | {
234 | "__id__": 10
235 | },
236 | {
237 | "__id__": 11
238 | }
239 | ],
240 | "_prefab": null,
241 | "_lpos": {
242 | "__type__": "cc.Vec3",
243 | "x": 0,
244 | "y": 0,
245 | "z": 0
246 | },
247 | "_lrot": {
248 | "__type__": "cc.Quat",
249 | "x": 0,
250 | "y": 0,
251 | "z": 0,
252 | "w": 1
253 | },
254 | "_lscale": {
255 | "__type__": "cc.Vec3",
256 | "x": 1,
257 | "y": 1,
258 | "z": 1
259 | },
260 | "_layer": 1,
261 | "_euler": {
262 | "__type__": "cc.Vec3",
263 | "x": 0,
264 | "y": 0,
265 | "z": 0
266 | },
267 | "_id": "2fUVfrgY9NRrX+cio35bw9"
268 | },
269 | {
270 | "__type__": "cc.Sprite",
271 | "_name": "",
272 | "_objFlags": 0,
273 | "node": {
274 | "__id__": 7
275 | },
276 | "_enabled": true,
277 | "__prefab": null,
278 | "_customMaterial": {
279 | "__uuid__": "fda095cb-831d-4601-ad94-846013963de8",
280 | "__expectedType__": "cc.Material"
281 | },
282 | "_srcBlendFactor": 2,
283 | "_dstBlendFactor": 4,
284 | "_color": {
285 | "__type__": "cc.Color",
286 | "r": 197,
287 | "g": 197,
288 | "b": 197,
289 | "a": 255
290 | },
291 | "_spriteFrame": {
292 | "__uuid__": "7d8f9b89-4fd1-4c9f-a3ab-38ec7cded7ca@f9941",
293 | "__expectedType__": "cc.SpriteFrame"
294 | },
295 | "_type": 0,
296 | "_fillType": 0,
297 | "_sizeMode": 0,
298 | "_fillCenter": {
299 | "__type__": "cc.Vec2",
300 | "x": 0,
301 | "y": 0
302 | },
303 | "_fillStart": 0,
304 | "_fillRange": 0,
305 | "_isTrimmedMode": false,
306 | "_useGrayscale": false,
307 | "_atlas": null,
308 | "_id": "61LUH7tyhDp4a/rKjWDA4V"
309 | },
310 | {
311 | "__type__": "cc.Widget",
312 | "_name": "",
313 | "_objFlags": 0,
314 | "node": {
315 | "__id__": 7
316 | },
317 | "_enabled": true,
318 | "__prefab": null,
319 | "_alignFlags": 45,
320 | "_target": null,
321 | "_left": 0,
322 | "_right": 0,
323 | "_top": 0,
324 | "_bottom": 0,
325 | "_horizontalCenter": 0,
326 | "_verticalCenter": 0,
327 | "_isAbsLeft": true,
328 | "_isAbsRight": true,
329 | "_isAbsTop": true,
330 | "_isAbsBottom": true,
331 | "_isAbsHorizontalCenter": true,
332 | "_isAbsVerticalCenter": true,
333 | "_originalWidth": 100,
334 | "_originalHeight": 100,
335 | "_alignMode": 2,
336 | "_lockFlags": 0,
337 | "_id": "58V7iCpjZLb7A5Z9/SI9eo"
338 | },
339 | {
340 | "__type__": "cc.UIOpacity",
341 | "_name": "",
342 | "_objFlags": 0,
343 | "node": {
344 | "__id__": 7
345 | },
346 | "_enabled": true,
347 | "__prefab": null,
348 | "_opacity": 255,
349 | "_id": "26PAWdHS1Hoa/1Bt6fqfh4"
350 | },
351 | {
352 | "__type__": "cc.UITransform",
353 | "_name": "",
354 | "_objFlags": 0,
355 | "node": {
356 | "__id__": 7
357 | },
358 | "_enabled": true,
359 | "__prefab": null,
360 | "_contentSize": {
361 | "__type__": "cc.Size",
362 | "width": 960,
363 | "height": 640
364 | },
365 | "_anchorPoint": {
366 | "__type__": "cc.Vec2",
367 | "x": 0.5,
368 | "y": 0.5
369 | },
370 | "_id": "5dFuISvHdCU5P6eud1Pgsu"
371 | },
372 | {
373 | "__type__": "cc.Node",
374 | "_name": "container",
375 | "_objFlags": 0,
376 | "_parent": {
377 | "__id__": 2
378 | },
379 | "_children": [
380 | {
381 | "__id__": 13
382 | },
383 | {
384 | "__id__": 18
385 | }
386 | ],
387 | "_active": true,
388 | "_components": [
389 | {
390 | "__id__": 22
391 | },
392 | {
393 | "__id__": 23
394 | },
395 | {
396 | "__id__": 24
397 | }
398 | ],
399 | "_prefab": null,
400 | "_lpos": {
401 | "__type__": "cc.Vec3",
402 | "x": 0,
403 | "y": 0,
404 | "z": 0
405 | },
406 | "_lrot": {
407 | "__type__": "cc.Quat",
408 | "x": 0,
409 | "y": 0,
410 | "z": 0,
411 | "w": 1
412 | },
413 | "_lscale": {
414 | "__type__": "cc.Vec3",
415 | "x": 1,
416 | "y": 1,
417 | "z": 1
418 | },
419 | "_layer": 1,
420 | "_euler": {
421 | "__type__": "cc.Vec3",
422 | "x": 0,
423 | "y": 0,
424 | "z": 0
425 | },
426 | "_id": "dbgQhRL3NGQbu+CONBhAiH"
427 | },
428 | {
429 | "__type__": "cc.Node",
430 | "_name": "img_fort",
431 | "_objFlags": 0,
432 | "_parent": {
433 | "__id__": 12
434 | },
435 | "_children": [],
436 | "_active": true,
437 | "_components": [
438 | {
439 | "__id__": 14
440 | },
441 | {
442 | "__id__": 15
443 | },
444 | {
445 | "__id__": 16
446 | },
447 | {
448 | "__id__": 17
449 | }
450 | ],
451 | "_prefab": null,
452 | "_lpos": {
453 | "__type__": "cc.Vec3",
454 | "x": 0,
455 | "y": 108,
456 | "z": 0
457 | },
458 | "_lrot": {
459 | "__type__": "cc.Quat",
460 | "x": 0,
461 | "y": 0,
462 | "z": 0,
463 | "w": 1
464 | },
465 | "_lscale": {
466 | "__type__": "cc.Vec3",
467 | "x": 1,
468 | "y": 1,
469 | "z": 1
470 | },
471 | "_layer": 1,
472 | "_euler": {
473 | "__type__": "cc.Vec3",
474 | "x": 0,
475 | "y": 0,
476 | "z": 0
477 | },
478 | "_id": "56HYDPtjRMgoZVxF733D5Y"
479 | },
480 | {
481 | "__type__": "cc.Sprite",
482 | "_name": "",
483 | "_objFlags": 0,
484 | "node": {
485 | "__id__": 13
486 | },
487 | "_enabled": true,
488 | "__prefab": null,
489 | "_customMaterial": {
490 | "__uuid__": "a0911d08-f9e8-4119-99b9-62c07e890f5f",
491 | "__expectedType__": "cc.Material"
492 | },
493 | "_srcBlendFactor": 2,
494 | "_dstBlendFactor": 4,
495 | "_color": {
496 | "__type__": "cc.Color",
497 | "r": 255,
498 | "g": 255,
499 | "b": 255,
500 | "a": 255
501 | },
502 | "_spriteFrame": {
503 | "__uuid__": "530d0a9f-ee1a-4b85-b306-7b50bf6d5ab5@f9941",
504 | "__expectedType__": "cc.SpriteFrame"
505 | },
506 | "_type": 0,
507 | "_fillType": 0,
508 | "_sizeMode": 0,
509 | "_fillCenter": {
510 | "__type__": "cc.Vec2",
511 | "x": 0,
512 | "y": 0
513 | },
514 | "_fillStart": 0,
515 | "_fillRange": 0,
516 | "_isTrimmedMode": false,
517 | "_useGrayscale": false,
518 | "_atlas": null,
519 | "_id": "0avbX6WYtCQIPhcpBZwtNg"
520 | },
521 | {
522 | "__type__": "6cb2bCUebpBfKggbh8qWfGL",
523 | "_name": "",
524 | "_objFlags": 0,
525 | "node": {
526 | "__id__": 13
527 | },
528 | "_enabled": true,
529 | "__prefab": null,
530 | "_id": "2eVPss595KIbU8w8E+hXtC"
531 | },
532 | {
533 | "__type__": "cc.UIOpacity",
534 | "_name": "",
535 | "_objFlags": 0,
536 | "node": {
537 | "__id__": 13
538 | },
539 | "_enabled": true,
540 | "__prefab": null,
541 | "_opacity": 255,
542 | "_id": "4bIeHH+MVAQpNeRiR5Wl7E"
543 | },
544 | {
545 | "__type__": "cc.UITransform",
546 | "_name": "",
547 | "_objFlags": 0,
548 | "node": {
549 | "__id__": 13
550 | },
551 | "_enabled": true,
552 | "__prefab": null,
553 | "_contentSize": {
554 | "__type__": "cc.Size",
555 | "width": 384,
556 | "height": 216
557 | },
558 | "_anchorPoint": {
559 | "__type__": "cc.Vec2",
560 | "x": 0.5,
561 | "y": 0.5
562 | },
563 | "_id": "f0Eheu7u5E0bNqdvEcq8j8"
564 | },
565 | {
566 | "__type__": "cc.Node",
567 | "_name": "img_fort",
568 | "_objFlags": 0,
569 | "_parent": {
570 | "__id__": 12
571 | },
572 | "_children": [],
573 | "_active": true,
574 | "_components": [
575 | {
576 | "__id__": 19
577 | },
578 | {
579 | "__id__": 20
580 | },
581 | {
582 | "__id__": 21
583 | }
584 | ],
585 | "_prefab": null,
586 | "_lpos": {
587 | "__type__": "cc.Vec3",
588 | "x": 0,
589 | "y": -108,
590 | "z": 0
591 | },
592 | "_lrot": {
593 | "__type__": "cc.Quat",
594 | "x": 0,
595 | "y": 0,
596 | "z": 0,
597 | "w": 1
598 | },
599 | "_lscale": {
600 | "__type__": "cc.Vec3",
601 | "x": 1,
602 | "y": 1,
603 | "z": 1
604 | },
605 | "_layer": 1,
606 | "_euler": {
607 | "__type__": "cc.Vec3",
608 | "x": 0,
609 | "y": 0,
610 | "z": 0
611 | },
612 | "_id": "57IynrYRREObXc65h3bEQp"
613 | },
614 | {
615 | "__type__": "cc.Sprite",
616 | "_name": "",
617 | "_objFlags": 0,
618 | "node": {
619 | "__id__": 18
620 | },
621 | "_enabled": true,
622 | "__prefab": null,
623 | "_customMaterial": null,
624 | "_srcBlendFactor": 2,
625 | "_dstBlendFactor": 4,
626 | "_color": {
627 | "__type__": "cc.Color",
628 | "r": 255,
629 | "g": 255,
630 | "b": 255,
631 | "a": 255
632 | },
633 | "_spriteFrame": {
634 | "__uuid__": "530d0a9f-ee1a-4b85-b306-7b50bf6d5ab5@f9941",
635 | "__expectedType__": "cc.SpriteFrame"
636 | },
637 | "_type": 0,
638 | "_fillType": 0,
639 | "_sizeMode": 0,
640 | "_fillCenter": {
641 | "__type__": "cc.Vec2",
642 | "x": 0,
643 | "y": 0
644 | },
645 | "_fillStart": 0,
646 | "_fillRange": 0,
647 | "_isTrimmedMode": false,
648 | "_useGrayscale": false,
649 | "_atlas": null,
650 | "_id": "32dxBNRb5I2pdalPCqd+gf"
651 | },
652 | {
653 | "__type__": "cc.UIOpacity",
654 | "_name": "",
655 | "_objFlags": 0,
656 | "node": {
657 | "__id__": 18
658 | },
659 | "_enabled": true,
660 | "__prefab": null,
661 | "_opacity": 255,
662 | "_id": "f2AZjMOzBAqbdQBIMT08Pi"
663 | },
664 | {
665 | "__type__": "cc.UITransform",
666 | "_name": "",
667 | "_objFlags": 0,
668 | "node": {
669 | "__id__": 18
670 | },
671 | "_enabled": true,
672 | "__prefab": null,
673 | "_contentSize": {
674 | "__type__": "cc.Size",
675 | "width": 384,
676 | "height": 216
677 | },
678 | "_anchorPoint": {
679 | "__type__": "cc.Vec2",
680 | "x": 0.5,
681 | "y": 0.5
682 | },
683 | "_id": "f5iJZIYcJLL47Gy+lGFjuQ"
684 | },
685 | {
686 | "__type__": "cc.Layout",
687 | "_name": "",
688 | "_objFlags": 0,
689 | "node": {
690 | "__id__": 12
691 | },
692 | "_enabled": true,
693 | "__prefab": null,
694 | "_resizeMode": 0,
695 | "_layoutType": 2,
696 | "_cellSize": {
697 | "__type__": "cc.Size",
698 | "width": 40,
699 | "height": 40
700 | },
701 | "_startAxis": 0,
702 | "_paddingLeft": 0,
703 | "_paddingRight": 0,
704 | "_paddingTop": 0,
705 | "_paddingBottom": 0,
706 | "_spacingX": 0,
707 | "_spacingY": 0,
708 | "_verticalDirection": 1,
709 | "_horizontalDirection": 0,
710 | "_constraint": 0,
711 | "_constraintNum": 2,
712 | "_affectedByScale": false,
713 | "_isAlign": true,
714 | "_id": "78/yEgCZRKW5MrKTYp8+yP"
715 | },
716 | {
717 | "__type__": "cc.UIOpacity",
718 | "_name": "",
719 | "_objFlags": 0,
720 | "node": {
721 | "__id__": 12
722 | },
723 | "_enabled": true,
724 | "__prefab": null,
725 | "_opacity": 255,
726 | "_id": "13X0+uPpZCTpQS4Ih4rFDK"
727 | },
728 | {
729 | "__type__": "cc.UITransform",
730 | "_name": "",
731 | "_objFlags": 0,
732 | "node": {
733 | "__id__": 12
734 | },
735 | "_enabled": true,
736 | "__prefab": null,
737 | "_contentSize": {
738 | "__type__": "cc.Size",
739 | "width": 384,
740 | "height": 432
741 | },
742 | "_anchorPoint": {
743 | "__type__": "cc.Vec2",
744 | "x": 0.5,
745 | "y": 0.5
746 | },
747 | "_id": "20FztQbF1CprJecJrfteB3"
748 | },
749 | {
750 | "__type__": "cc.Canvas",
751 | "_name": "",
752 | "_objFlags": 0,
753 | "node": {
754 | "__id__": 2
755 | },
756 | "_enabled": true,
757 | "__prefab": null,
758 | "_cameraComponent": {
759 | "__id__": 4
760 | },
761 | "_alignCanvasWithScreen": true,
762 | "_id": "27hFDZANZCb45Zgm4KlZTN"
763 | },
764 | {
765 | "__type__": "cc.Widget",
766 | "_name": "",
767 | "_objFlags": 0,
768 | "node": {
769 | "__id__": 2
770 | },
771 | "_enabled": true,
772 | "__prefab": null,
773 | "_alignFlags": 45,
774 | "_target": null,
775 | "_left": 0,
776 | "_right": 0,
777 | "_top": 0,
778 | "_bottom": 0,
779 | "_horizontalCenter": 0,
780 | "_verticalCenter": 0,
781 | "_isAbsLeft": true,
782 | "_isAbsRight": true,
783 | "_isAbsTop": true,
784 | "_isAbsBottom": true,
785 | "_isAbsHorizontalCenter": true,
786 | "_isAbsVerticalCenter": true,
787 | "_originalWidth": 0,
788 | "_originalHeight": 0,
789 | "_alignMode": 2,
790 | "_lockFlags": 0,
791 | "_id": "1eSSkzy5tMlJ6AhJoz1o5X"
792 | },
793 | {
794 | "__type__": "cc.UIOpacity",
795 | "_name": "",
796 | "_objFlags": 0,
797 | "node": {
798 | "__id__": 2
799 | },
800 | "_enabled": true,
801 | "__prefab": null,
802 | "_opacity": 255,
803 | "_id": "0fo0lnKD5LroU1GstQO1nd"
804 | },
805 | {
806 | "__type__": "cc.UITransform",
807 | "_name": "",
808 | "_objFlags": 0,
809 | "node": {
810 | "__id__": 2
811 | },
812 | "_enabled": true,
813 | "__prefab": null,
814 | "_contentSize": {
815 | "__type__": "cc.Size",
816 | "width": 960,
817 | "height": 640
818 | },
819 | "_anchorPoint": {
820 | "__type__": "cc.Vec2",
821 | "x": 0.5,
822 | "y": 0.5
823 | },
824 | "_id": "cfNGKaVpRLCbqd7WnQhanN"
825 | },
826 | {
827 | "__type__": "cc.PrefabInfo",
828 | "fileId": "cdb032e3-6bd3-449a-9f85-ad28907565d4"
829 | },
830 | {
831 | "__type__": "cc.SceneGlobals",
832 | "ambient": {
833 | "__id__": 31
834 | },
835 | "shadows": {
836 | "__id__": 32
837 | },
838 | "_skybox": {
839 | "__id__": 33
840 | },
841 | "fog": {
842 | "__id__": 34
843 | },
844 | "octree": {
845 | "__id__": 35
846 | }
847 | },
848 | {
849 | "__type__": "cc.AmbientInfo",
850 | "_skyColorHDR": {
851 | "__type__": "cc.Vec4",
852 | "x": 0.2,
853 | "y": 0.5019607843137255,
854 | "z": 0.8,
855 | "w": 0.520833125
856 | },
857 | "_skyColor": {
858 | "__type__": "cc.Vec4",
859 | "x": 0.2,
860 | "y": 0.5019607843137255,
861 | "z": 0.8,
862 | "w": 0.520833125
863 | },
864 | "_skyIllumHDR": 20000,
865 | "_skyIllum": 20000,
866 | "_groundAlbedoHDR": {
867 | "__type__": "cc.Vec4",
868 | "x": 0.2,
869 | "y": 0.2,
870 | "z": 0.2,
871 | "w": 1
872 | },
873 | "_groundAlbedo": {
874 | "__type__": "cc.Vec4",
875 | "x": 0.2,
876 | "y": 0.2,
877 | "z": 0.2,
878 | "w": 1
879 | },
880 | "_skyColorLDR": {
881 | "__type__": "cc.Vec4",
882 | "x": 0.2,
883 | "y": 0.5019607843137255,
884 | "z": 0.8,
885 | "w": 0.520833125
886 | },
887 | "_skyIllumLDR": 0.78125,
888 | "_groundAlbedoLDR": {
889 | "__type__": "cc.Vec4",
890 | "x": 0.2,
891 | "y": 0.2,
892 | "z": 0.2,
893 | "w": 1
894 | }
895 | },
896 | {
897 | "__type__": "cc.ShadowsInfo",
898 | "_enabled": false,
899 | "_type": 0,
900 | "_normal": {
901 | "__type__": "cc.Vec3",
902 | "x": 0,
903 | "y": 1,
904 | "z": 0
905 | },
906 | "_distance": 0,
907 | "_shadowColor": {
908 | "__type__": "cc.Color",
909 | "r": 0,
910 | "g": 0,
911 | "b": 0,
912 | "a": 76
913 | },
914 | "_maxReceived": 4,
915 | "_size": {
916 | "__type__": "cc.Vec2",
917 | "x": 512,
918 | "y": 512
919 | }
920 | },
921 | {
922 | "__type__": "cc.SkyboxInfo",
923 | "_envLightingType": 0,
924 | "_envmapHDR": null,
925 | "_envmap": null,
926 | "_envmapLDR": null,
927 | "_diffuseMapHDR": null,
928 | "_diffuseMapLDR": null,
929 | "_enabled": false,
930 | "_useHDR": true,
931 | "_editableMaterial": null,
932 | "_reflectionHDR": null,
933 | "_reflectionLDR": null
934 | },
935 | {
936 | "__type__": "cc.FogInfo",
937 | "_type": 0,
938 | "_fogColor": {
939 | "__type__": "cc.Color",
940 | "r": 225,
941 | "g": 225,
942 | "b": 225,
943 | "a": 255
944 | },
945 | "_enabled": false,
946 | "_fogDensity": 0.3,
947 | "_fogStart": 0.5,
948 | "_fogEnd": 300,
949 | "_fogAtten": 5,
950 | "_fogTop": 1.5,
951 | "_fogRange": 1.2,
952 | "_accurate": false
953 | },
954 | {
955 | "__type__": "cc.OctreeInfo",
956 | "_enabled": false,
957 | "_minPos": {
958 | "__type__": "cc.Vec3",
959 | "x": -1024,
960 | "y": -1024,
961 | "z": -1024
962 | },
963 | "_maxPos": {
964 | "__type__": "cc.Vec3",
965 | "x": 1024,
966 | "y": 1024,
967 | "z": 1024
968 | },
969 | "_depth": 8
970 | }
971 | ]
--------------------------------------------------------------------------------
/assets/case/03_flash/flash.scene.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.39",
3 | "importer": "scene",
4 | "imported": true,
5 | "uuid": "cdb032e3-6bd3-449a-9f85-ad28907565d4",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/03_flash/flash.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: yansixing
3 | * @Date: 2019-07-30 08:22:32
4 | * @Github: https://github.com/yansixing
5 | * @LastEditTime: 2021-05-23 16:11:42
6 | */
7 |
8 | import { _decorator, Component, Sprite, Material } from 'cc';
9 | const { ccclass, property, executeInEditMode } = _decorator;
10 |
11 | @ccclass('Flash')
12 | @executeInEditMode
13 | export default class Flash extends Component {
14 | // @property
15 | // enabled: boolean = true;
16 | // @property
17 | // outlineColor: string = "0xffffff";
18 | // @property
19 | // outlineSize: number = 2;
20 | img: Sprite | null = null;
21 | material: Material | undefined | null = null;
22 | startTime: number = Date.now();
23 | time: number = 0;
24 | onLoad() {
25 |
26 | this.img = this.getComponent(Sprite);
27 | this.material = this.img?.sharedMaterial;
28 |
29 | //console.log(this.material);
30 | }
31 | update() {
32 | this.time = (Date.now() - this.startTime) / 1000;
33 | this.material?.setProperty("time", this.time);
34 | // this.material?.effect?.setProperty('time', this.time);
35 | }
36 | }
--------------------------------------------------------------------------------
/assets/case/03_flash/flash.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "4.0.23",
3 | "importer": "typescript",
4 | "imported": true,
5 | "uuid": "6cb2b094-79ba-417c-a820-6e1f2a59f18b",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "simulateGlobals": []
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/04_shadow.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.0",
3 | "importer": "directory",
4 | "imported": true,
5 | "uuid": "891afb78-bbe0-4883-bbe6-2c51b41fded9",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "compressionType": {},
10 | "isRemoteBundle": {}
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/assets/case/04_shadow/shadow.effect:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
2 | CCEffect %{
3 | techniques:
4 | - passes:
5 | - vert: sprite-vs:vert
6 | frag: sprite-fs:frag
7 | depthStencilState:
8 | depthTest: false
9 | depthWrite: false
10 | blendState:
11 | targets:
12 | - blend: true
13 | blendSrc: src_alpha
14 | blendDst: one_minus_src_alpha
15 | blendDstAlpha: one_minus_src_alpha
16 | rasterizerState:
17 | cullMode: none
18 | properties:
19 | alphaThreshold: { value: 0.5 }
20 | isWhite: { value: -1.0 }
21 | }%
22 |
23 | CCProgram sprite-vs %{
24 | precision highp float;
25 | #include
26 | #if USE_LOCAL
27 | #include
28 | #endif
29 |
30 | in vec3 a_position;
31 | in vec2 a_texCoord;
32 | in vec4 a_color;
33 |
34 | out vec4 color;
35 | out vec2 uv0;
36 |
37 | vec4 vert () {
38 | vec4 pos = vec4(a_position, 1);
39 |
40 | #if USE_LOCAL
41 | pos = cc_matWorld * pos;
42 | #endif
43 |
44 | #if USE_PIXEL_ALIGNMENT
45 | pos = cc_matView * pos;
46 | pos.xyz = floor(pos.xyz);
47 | pos = cc_matProj * pos;
48 | #else
49 | pos = cc_matViewProj * pos;
50 | #endif
51 |
52 | uv0 = a_texCoord;
53 |
54 | color = a_color;
55 |
56 | return pos;
57 | }
58 | }%
59 |
60 | CCProgram sprite-fs %{
61 | precision highp float;
62 | #include
63 | #include
64 |
65 | in vec4 color;
66 |
67 | #if USE_TEXTURE
68 | in vec2 uv0;
69 | #pragma builtin(local)
70 | layout(set = 2, binding = 10) uniform sampler2D cc_spriteTexture;
71 | #endif
72 |
73 | uniform FragConstants {
74 | float isWhite;
75 | };
76 |
77 | vec4 composite(vec4 over, vec4 under)
78 | {
79 | return over + (1.0 - over.a)*under;
80 | }
81 | vec4 getColor(vec4 color){
82 | if(isWhite > 0.0){
83 | if(color.a > 0.0){
84 | return vec4(1.0,1.0,1.0,1.0);
85 | }
86 | return color;
87 | }
88 | return color;
89 | }
90 |
91 | vec4 frag () {
92 | vec2 shadowOffset = vec2(-0.0, -0.2);
93 | vec4 textureColor = CCSampleWithAlphaSeparated(cc_spriteTexture,uv0 );
94 | float shadowMask = CCSampleWithAlphaSeparated(cc_spriteTexture,uv0 +shadowOffset ).a;
95 | const float shadowOpacity = 0.5;
96 | vec4 shadowColor = vec4(0.0,0.0,0.0,shadowMask*shadowOpacity);
97 | textureColor = getColor(textureColor);
98 | return composite(textureColor,shadowColor);
99 | }
100 | }%
101 |
--------------------------------------------------------------------------------
/assets/case/04_shadow/shadow.effect.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.5.9",
3 | "importer": "effect",
4 | "imported": true,
5 | "uuid": "8c3e3d69-859a-456b-a16b-34e7de0db642",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/04_shadow/shadow.mtl:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.Material",
3 | "_name": "",
4 | "_objFlags": 0,
5 | "_native": "",
6 | "_effectAsset": {
7 | "__uuid__": "8c3e3d69-859a-456b-a16b-34e7de0db642"
8 | },
9 | "_techIdx": 0,
10 | "_defines": [
11 | {
12 | "USE_TEXTURE": true
13 | }
14 | ],
15 | "_states": [
16 | {
17 | "rasterizerState": {},
18 | "depthStencilState": {},
19 | "blendState": {
20 | "targets": [
21 | {}
22 | ]
23 | }
24 | }
25 | ],
26 | "_props": [
27 | {}
28 | ]
29 | }
--------------------------------------------------------------------------------
/assets/case/04_shadow/shadow.mtl.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.13",
3 | "importer": "material",
4 | "imported": true,
5 | "uuid": "66788f77-0104-4be4-ba1c-88fe443afcf5",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/04_shadow/shadow.scene:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.SceneAsset",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "scene": {
8 | "__id__": 1
9 | }
10 | },
11 | {
12 | "__type__": "cc.Scene",
13 | "_name": "shadow",
14 | "_objFlags": 0,
15 | "_parent": null,
16 | "_children": [
17 | {
18 | "__id__": 2
19 | }
20 | ],
21 | "_active": true,
22 | "_components": [],
23 | "_prefab": {
24 | "__id__": 21
25 | },
26 | "autoReleaseAssets": false,
27 | "_globals": {
28 | "__id__": 22
29 | },
30 | "_id": "a97f42a4-95dc-472a-9565-b3d2ce7c5206"
31 | },
32 | {
33 | "__type__": "cc.Node",
34 | "_name": "Canvas",
35 | "_objFlags": 0,
36 | "_parent": {
37 | "__id__": 1
38 | },
39 | "_children": [
40 | {
41 | "__id__": 3
42 | },
43 | {
44 | "__id__": 7
45 | },
46 | {
47 | "__id__": 12
48 | }
49 | ],
50 | "_active": true,
51 | "_components": [
52 | {
53 | "__id__": 17
54 | },
55 | {
56 | "__id__": 18
57 | },
58 | {
59 | "__id__": 19
60 | },
61 | {
62 | "__id__": 20
63 | }
64 | ],
65 | "_prefab": null,
66 | "_lpos": {
67 | "__type__": "cc.Vec3",
68 | "x": 480,
69 | "y": 320,
70 | "z": 0
71 | },
72 | "_lrot": {
73 | "__type__": "cc.Quat",
74 | "x": 0,
75 | "y": 0,
76 | "z": 0,
77 | "w": 1
78 | },
79 | "_lscale": {
80 | "__type__": "cc.Vec3",
81 | "x": 1,
82 | "y": 1,
83 | "z": 1
84 | },
85 | "_layer": 1,
86 | "_euler": {
87 | "__type__": "cc.Vec3",
88 | "x": 0,
89 | "y": 0,
90 | "z": 0
91 | },
92 | "_id": "d6Ngmh6ZRGFJLRuR75koHM"
93 | },
94 | {
95 | "__type__": "cc.Node",
96 | "_name": "Main Camera",
97 | "_objFlags": 0,
98 | "_parent": {
99 | "__id__": 2
100 | },
101 | "_children": [],
102 | "_active": true,
103 | "_components": [
104 | {
105 | "__id__": 4
106 | },
107 | {
108 | "__id__": 5
109 | },
110 | {
111 | "__id__": 6
112 | }
113 | ],
114 | "_prefab": null,
115 | "_lpos": {
116 | "__type__": "cc.Vec3",
117 | "x": 0,
118 | "y": 0,
119 | "z": 1000
120 | },
121 | "_lrot": {
122 | "__type__": "cc.Quat",
123 | "x": 0,
124 | "y": 0,
125 | "z": 0,
126 | "w": 1
127 | },
128 | "_lscale": {
129 | "__type__": "cc.Vec3",
130 | "x": 1,
131 | "y": 1,
132 | "z": 1
133 | },
134 | "_layer": 1,
135 | "_euler": {
136 | "__type__": "cc.Vec3",
137 | "x": 0,
138 | "y": 0,
139 | "z": 0
140 | },
141 | "_id": "famfQa9lNNDpy1laptVx12"
142 | },
143 | {
144 | "__type__": "cc.Camera",
145 | "_name": "",
146 | "_objFlags": 0,
147 | "node": {
148 | "__id__": 3
149 | },
150 | "_enabled": true,
151 | "__prefab": null,
152 | "_projection": 0,
153 | "_priority": -1,
154 | "_fov": 60,
155 | "_fovAxis": 0,
156 | "_orthoHeight": 426.31989596879066,
157 | "_near": 1,
158 | "_far": 4096,
159 | "_color": {
160 | "__type__": "cc.Color",
161 | "r": 0,
162 | "g": 0,
163 | "b": 0,
164 | "a": 255
165 | },
166 | "_depth": 1,
167 | "_stencil": 0,
168 | "_clearFlags": 7,
169 | "_rect": {
170 | "__type__": "cc.Rect",
171 | "x": 0,
172 | "y": 0,
173 | "width": 1,
174 | "height": 1
175 | },
176 | "_aperture": 19,
177 | "_shutter": 7,
178 | "_iso": 0,
179 | "_screenScale": 1,
180 | "_visibility": 4294967295,
181 | "_targetTexture": null,
182 | "_id": "12FxhQCQhKjLi1OSAfGzBd"
183 | },
184 | {
185 | "__type__": "cc.UIOpacity",
186 | "_name": "",
187 | "_objFlags": 0,
188 | "node": {
189 | "__id__": 3
190 | },
191 | "_enabled": true,
192 | "__prefab": null,
193 | "_opacity": 255,
194 | "_id": "a0zFfddyJC2YGHXTQ3+6V6"
195 | },
196 | {
197 | "__type__": "cc.UITransform",
198 | "_name": "",
199 | "_objFlags": 0,
200 | "node": {
201 | "__id__": 3
202 | },
203 | "_enabled": true,
204 | "__prefab": null,
205 | "_contentSize": {
206 | "__type__": "cc.Size",
207 | "width": 0,
208 | "height": 0
209 | },
210 | "_anchorPoint": {
211 | "__type__": "cc.Vec2",
212 | "x": 0.5,
213 | "y": 0.5
214 | },
215 | "_id": "6cYrb8X3JCoKBj0fIs9bbz"
216 | },
217 | {
218 | "__type__": "cc.Node",
219 | "_name": "bg",
220 | "_objFlags": 0,
221 | "_parent": {
222 | "__id__": 2
223 | },
224 | "_children": [],
225 | "_active": true,
226 | "_components": [
227 | {
228 | "__id__": 8
229 | },
230 | {
231 | "__id__": 9
232 | },
233 | {
234 | "__id__": 10
235 | },
236 | {
237 | "__id__": 11
238 | }
239 | ],
240 | "_prefab": null,
241 | "_lpos": {
242 | "__type__": "cc.Vec3",
243 | "x": 0,
244 | "y": 0,
245 | "z": 0
246 | },
247 | "_lrot": {
248 | "__type__": "cc.Quat",
249 | "x": 0,
250 | "y": 0,
251 | "z": 0,
252 | "w": 1
253 | },
254 | "_lscale": {
255 | "__type__": "cc.Vec3",
256 | "x": 1,
257 | "y": 1,
258 | "z": 1
259 | },
260 | "_layer": 1,
261 | "_euler": {
262 | "__type__": "cc.Vec3",
263 | "x": 0,
264 | "y": 0,
265 | "z": 0
266 | },
267 | "_id": "2fUVfrgY9NRrX+cio35bw9"
268 | },
269 | {
270 | "__type__": "cc.Sprite",
271 | "_name": "",
272 | "_objFlags": 0,
273 | "node": {
274 | "__id__": 7
275 | },
276 | "_enabled": true,
277 | "__prefab": null,
278 | "_customMaterial": {
279 | "__uuid__": "fda095cb-831d-4601-ad94-846013963de8",
280 | "__expectedType__": "cc.Material"
281 | },
282 | "_srcBlendFactor": 2,
283 | "_dstBlendFactor": 4,
284 | "_color": {
285 | "__type__": "cc.Color",
286 | "r": 197,
287 | "g": 197,
288 | "b": 197,
289 | "a": 255
290 | },
291 | "_spriteFrame": {
292 | "__uuid__": "7d8f9b89-4fd1-4c9f-a3ab-38ec7cded7ca@f9941",
293 | "__expectedType__": "cc.SpriteFrame"
294 | },
295 | "_type": 0,
296 | "_fillType": 0,
297 | "_sizeMode": 0,
298 | "_fillCenter": {
299 | "__type__": "cc.Vec2",
300 | "x": 0,
301 | "y": 0
302 | },
303 | "_fillStart": 0,
304 | "_fillRange": 0,
305 | "_isTrimmedMode": false,
306 | "_useGrayscale": false,
307 | "_atlas": null,
308 | "_id": "61LUH7tyhDp4a/rKjWDA4V"
309 | },
310 | {
311 | "__type__": "cc.Widget",
312 | "_name": "",
313 | "_objFlags": 0,
314 | "node": {
315 | "__id__": 7
316 | },
317 | "_enabled": true,
318 | "__prefab": null,
319 | "_alignFlags": 45,
320 | "_target": null,
321 | "_left": 0,
322 | "_right": 0,
323 | "_top": 0,
324 | "_bottom": 0,
325 | "_horizontalCenter": 0,
326 | "_verticalCenter": 0,
327 | "_isAbsLeft": true,
328 | "_isAbsRight": true,
329 | "_isAbsTop": true,
330 | "_isAbsBottom": true,
331 | "_isAbsHorizontalCenter": true,
332 | "_isAbsVerticalCenter": true,
333 | "_originalWidth": 100,
334 | "_originalHeight": 100,
335 | "_alignMode": 2,
336 | "_lockFlags": 0,
337 | "_id": "58V7iCpjZLb7A5Z9/SI9eo"
338 | },
339 | {
340 | "__type__": "cc.UIOpacity",
341 | "_name": "",
342 | "_objFlags": 0,
343 | "node": {
344 | "__id__": 7
345 | },
346 | "_enabled": true,
347 | "__prefab": null,
348 | "_opacity": 255,
349 | "_id": "d1UX+Bh3FKcr5re6Zvf24O"
350 | },
351 | {
352 | "__type__": "cc.UITransform",
353 | "_name": "",
354 | "_objFlags": 0,
355 | "node": {
356 | "__id__": 7
357 | },
358 | "_enabled": true,
359 | "__prefab": null,
360 | "_contentSize": {
361 | "__type__": "cc.Size",
362 | "width": 960,
363 | "height": 640
364 | },
365 | "_anchorPoint": {
366 | "__type__": "cc.Vec2",
367 | "x": 0.5,
368 | "y": 0.5
369 | },
370 | "_id": "12B0slZ6REUoXIW51+DEz5"
371 | },
372 | {
373 | "__type__": "cc.Node",
374 | "_name": "img_fort",
375 | "_objFlags": 0,
376 | "_parent": {
377 | "__id__": 2
378 | },
379 | "_children": [],
380 | "_active": true,
381 | "_components": [
382 | {
383 | "__id__": 13
384 | },
385 | {
386 | "__id__": 14
387 | },
388 | {
389 | "__id__": 15
390 | },
391 | {
392 | "__id__": 16
393 | }
394 | ],
395 | "_prefab": null,
396 | "_lpos": {
397 | "__type__": "cc.Vec3",
398 | "x": 0,
399 | "y": 0,
400 | "z": 0
401 | },
402 | "_lrot": {
403 | "__type__": "cc.Quat",
404 | "x": 0,
405 | "y": 0,
406 | "z": 0,
407 | "w": 1
408 | },
409 | "_lscale": {
410 | "__type__": "cc.Vec3",
411 | "x": 1,
412 | "y": 1,
413 | "z": 1
414 | },
415 | "_layer": 1,
416 | "_euler": {
417 | "__type__": "cc.Vec3",
418 | "x": 0,
419 | "y": 0,
420 | "z": 0
421 | },
422 | "_id": "57IynrYRREObXc65h3bEQp"
423 | },
424 | {
425 | "__type__": "cc.Sprite",
426 | "_name": "",
427 | "_objFlags": 0,
428 | "node": {
429 | "__id__": 12
430 | },
431 | "_enabled": true,
432 | "__prefab": null,
433 | "_customMaterial": {
434 | "__uuid__": "66788f77-0104-4be4-ba1c-88fe443afcf5",
435 | "__expectedType__": "cc.Material"
436 | },
437 | "_srcBlendFactor": 2,
438 | "_dstBlendFactor": 4,
439 | "_color": {
440 | "__type__": "cc.Color",
441 | "r": 255,
442 | "g": 255,
443 | "b": 255,
444 | "a": 255
445 | },
446 | "_spriteFrame": {
447 | "__uuid__": "b99ff1e7-ac1e-4e2c-80a9-b0ae8fccab8a@f9941",
448 | "__expectedType__": "cc.SpriteFrame"
449 | },
450 | "_type": 0,
451 | "_fillType": 0,
452 | "_sizeMode": 2,
453 | "_fillCenter": {
454 | "__type__": "cc.Vec2",
455 | "x": 0,
456 | "y": 0
457 | },
458 | "_fillStart": 0,
459 | "_fillRange": 0,
460 | "_isTrimmedMode": false,
461 | "_useGrayscale": false,
462 | "_atlas": null,
463 | "_id": "32dxBNRb5I2pdalPCqd+gf"
464 | },
465 | {
466 | "__type__": "0dc12HzhHtBzqVehoUYGkj2",
467 | "_name": "",
468 | "_objFlags": 0,
469 | "node": {
470 | "__id__": 12
471 | },
472 | "_enabled": true,
473 | "__prefab": null,
474 | "isWhite": false,
475 | "_id": "2byaJiqm1OlKmeMI9Ehq5W"
476 | },
477 | {
478 | "__type__": "cc.UIOpacity",
479 | "_name": "",
480 | "_objFlags": 0,
481 | "node": {
482 | "__id__": 12
483 | },
484 | "_enabled": true,
485 | "__prefab": null,
486 | "_opacity": 255,
487 | "_id": "8faivFU7JMqIunjMgb29M3"
488 | },
489 | {
490 | "__type__": "cc.UITransform",
491 | "_name": "",
492 | "_objFlags": 0,
493 | "node": {
494 | "__id__": 12
495 | },
496 | "_enabled": true,
497 | "__prefab": null,
498 | "_contentSize": {
499 | "__type__": "cc.Size",
500 | "width": 300,
501 | "height": 200
502 | },
503 | "_anchorPoint": {
504 | "__type__": "cc.Vec2",
505 | "x": 0.5,
506 | "y": 0.5
507 | },
508 | "_id": "0bCb6XmGhNTpIOA/NSC9cZ"
509 | },
510 | {
511 | "__type__": "cc.Canvas",
512 | "_name": "",
513 | "_objFlags": 0,
514 | "node": {
515 | "__id__": 2
516 | },
517 | "_enabled": true,
518 | "__prefab": null,
519 | "_cameraComponent": {
520 | "__id__": 4
521 | },
522 | "_alignCanvasWithScreen": true,
523 | "_id": "27hFDZANZCb45Zgm4KlZTN"
524 | },
525 | {
526 | "__type__": "cc.Widget",
527 | "_name": "",
528 | "_objFlags": 0,
529 | "node": {
530 | "__id__": 2
531 | },
532 | "_enabled": true,
533 | "__prefab": null,
534 | "_alignFlags": 45,
535 | "_target": null,
536 | "_left": 0,
537 | "_right": 0,
538 | "_top": 0,
539 | "_bottom": 0,
540 | "_horizontalCenter": 0,
541 | "_verticalCenter": 0,
542 | "_isAbsLeft": true,
543 | "_isAbsRight": true,
544 | "_isAbsTop": true,
545 | "_isAbsBottom": true,
546 | "_isAbsHorizontalCenter": true,
547 | "_isAbsVerticalCenter": true,
548 | "_originalWidth": 0,
549 | "_originalHeight": 0,
550 | "_alignMode": 2,
551 | "_lockFlags": 0,
552 | "_id": "b6pzJgtSlFL6Wt9xO8Ai7/"
553 | },
554 | {
555 | "__type__": "cc.UIOpacity",
556 | "_name": "",
557 | "_objFlags": 0,
558 | "node": {
559 | "__id__": 2
560 | },
561 | "_enabled": true,
562 | "__prefab": null,
563 | "_opacity": 255,
564 | "_id": "75hK0Hq1BE/6VJwjGkA2Oy"
565 | },
566 | {
567 | "__type__": "cc.UITransform",
568 | "_name": "",
569 | "_objFlags": 0,
570 | "node": {
571 | "__id__": 2
572 | },
573 | "_enabled": true,
574 | "__prefab": null,
575 | "_contentSize": {
576 | "__type__": "cc.Size",
577 | "width": 960,
578 | "height": 640
579 | },
580 | "_anchorPoint": {
581 | "__type__": "cc.Vec2",
582 | "x": 0.5,
583 | "y": 0.5
584 | },
585 | "_id": "6dKMPvhRlC65blhYsWXd4B"
586 | },
587 | {
588 | "__type__": "cc.PrefabInfo",
589 | "fileId": "a97f42a4-95dc-472a-9565-b3d2ce7c5206"
590 | },
591 | {
592 | "__type__": "cc.SceneGlobals",
593 | "ambient": {
594 | "__id__": 23
595 | },
596 | "shadows": {
597 | "__id__": 24
598 | },
599 | "_skybox": {
600 | "__id__": 25
601 | },
602 | "fog": {
603 | "__id__": 26
604 | },
605 | "octree": {
606 | "__id__": 27
607 | }
608 | },
609 | {
610 | "__type__": "cc.AmbientInfo",
611 | "_skyColorHDR": {
612 | "__type__": "cc.Vec4",
613 | "x": 0.2,
614 | "y": 0.5019607843137255,
615 | "z": 0.8,
616 | "w": 0.520833125
617 | },
618 | "_skyColor": {
619 | "__type__": "cc.Vec4",
620 | "x": 0.2,
621 | "y": 0.5019607843137255,
622 | "z": 0.8,
623 | "w": 0.520833125
624 | },
625 | "_skyIllumHDR": 20000,
626 | "_skyIllum": 20000,
627 | "_groundAlbedoHDR": {
628 | "__type__": "cc.Vec4",
629 | "x": 0.2,
630 | "y": 0.2,
631 | "z": 0.2,
632 | "w": 1
633 | },
634 | "_groundAlbedo": {
635 | "__type__": "cc.Vec4",
636 | "x": 0.2,
637 | "y": 0.2,
638 | "z": 0.2,
639 | "w": 1
640 | },
641 | "_skyColorLDR": {
642 | "__type__": "cc.Vec4",
643 | "x": 0.2,
644 | "y": 0.5019607843137255,
645 | "z": 0.8,
646 | "w": 0.520833125
647 | },
648 | "_skyIllumLDR": 0.78125,
649 | "_groundAlbedoLDR": {
650 | "__type__": "cc.Vec4",
651 | "x": 0.2,
652 | "y": 0.2,
653 | "z": 0.2,
654 | "w": 1
655 | }
656 | },
657 | {
658 | "__type__": "cc.ShadowsInfo",
659 | "_enabled": false,
660 | "_type": 0,
661 | "_normal": {
662 | "__type__": "cc.Vec3",
663 | "x": 0,
664 | "y": 1,
665 | "z": 0
666 | },
667 | "_distance": 0,
668 | "_shadowColor": {
669 | "__type__": "cc.Color",
670 | "r": 0,
671 | "g": 0,
672 | "b": 0,
673 | "a": 76
674 | },
675 | "_maxReceived": 4,
676 | "_size": {
677 | "__type__": "cc.Vec2",
678 | "x": 512,
679 | "y": 512
680 | }
681 | },
682 | {
683 | "__type__": "cc.SkyboxInfo",
684 | "_envLightingType": 0,
685 | "_envmapHDR": null,
686 | "_envmap": null,
687 | "_envmapLDR": null,
688 | "_diffuseMapHDR": null,
689 | "_diffuseMapLDR": null,
690 | "_enabled": false,
691 | "_useHDR": true,
692 | "_editableMaterial": null,
693 | "_reflectionHDR": null,
694 | "_reflectionLDR": null
695 | },
696 | {
697 | "__type__": "cc.FogInfo",
698 | "_type": 0,
699 | "_fogColor": {
700 | "__type__": "cc.Color",
701 | "r": 225,
702 | "g": 225,
703 | "b": 225,
704 | "a": 255
705 | },
706 | "_enabled": false,
707 | "_fogDensity": 0.3,
708 | "_fogStart": 0.5,
709 | "_fogEnd": 300,
710 | "_fogAtten": 5,
711 | "_fogTop": 1.5,
712 | "_fogRange": 1.2,
713 | "_accurate": false
714 | },
715 | {
716 | "__type__": "cc.OctreeInfo",
717 | "_enabled": false,
718 | "_minPos": {
719 | "__type__": "cc.Vec3",
720 | "x": -1024,
721 | "y": -1024,
722 | "z": -1024
723 | },
724 | "_maxPos": {
725 | "__type__": "cc.Vec3",
726 | "x": 1024,
727 | "y": 1024,
728 | "z": 1024
729 | },
730 | "_depth": 8
731 | }
732 | ]
--------------------------------------------------------------------------------
/assets/case/04_shadow/shadow.scene.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.39",
3 | "importer": "scene",
4 | "imported": true,
5 | "uuid": "a97f42a4-95dc-472a-9565-b3d2ce7c5206",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/04_shadow/shadow.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: yansixing
3 | * @Date: 2019-07-30 08:22:32
4 | * @Github: https://github.com/yansixing
5 | * @LastEditTime: 2021-05-23 16:17:42
6 | */
7 |
8 | import { _decorator, Component, Sprite, Material } from 'cc';
9 | const { ccclass, property } = _decorator;
10 |
11 | @ccclass('Shadow')
12 | export default class Shadow extends Component {
13 | // @property
14 | // outlineColor: string = "0xffffff";
15 | // @property
16 | // outlineSize: number = 2;
17 | @property
18 | isWhite: boolean = false;
19 | img: Sprite | null = null;
20 | material: Material | undefined | null = null;
21 | onLoad() {
22 | //this.img = this.getComponent(cc.Sprite);
23 | //this.material = this.img.getMaterial(0);
24 |
25 | //this.material.effect.setProperty('isWhite', this.isWhite ? 1.0 : -1.0);
26 | //console.log(this.material);
27 | }
28 | }
--------------------------------------------------------------------------------
/assets/case/04_shadow/shadow.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "4.0.23",
3 | "importer": "typescript",
4 | "imported": true,
5 | "uuid": "0dc121f3-847b-41ce-a55e-8685181a48f6",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "simulateGlobals": []
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/05_gaussBlur.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.0",
3 | "importer": "directory",
4 | "imported": true,
5 | "uuid": "2ac68b07-9b83-4836-90b7-b32630823885",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "compressionType": {},
10 | "isRemoteBundle": {}
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/assets/case/05_gaussBlur/gaussBlur.effect:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
2 | CCEffect %{
3 | techniques:
4 | - passes:
5 | - vert: sprite-vs:vert
6 | frag: sprite-fs:frag
7 | depthStencilState:
8 | depthTest: false
9 | depthWrite: false
10 | blendState:
11 | targets:
12 | - blend: true
13 | blendSrc: src_alpha
14 | blendDst: one_minus_src_alpha
15 | blendDstAlpha: one_minus_src_alpha
16 | rasterizerState:
17 | cullMode: none
18 | properties:
19 | alphaThreshold: { value: 0.5 }
20 | bluramount: { value: 0.03 }
21 | }%
22 |
23 | CCProgram sprite-vs %{
24 | precision highp float;
25 | #include
26 | #if USE_LOCAL
27 | #include
28 | #endif
29 | in vec3 a_position;
30 | in vec2 a_texCoord;
31 | in vec4 a_color;
32 |
33 | out vec4 color;
34 | out vec2 uv0;
35 |
36 | vec4 vert () {
37 | vec4 pos = vec4(a_position, 1);
38 |
39 | #if USE_LOCAL
40 | pos = cc_matWorld * pos;
41 | #endif
42 |
43 | #if USE_PIXEL_ALIGNMENT
44 | pos = cc_matView * pos;
45 | pos.xyz = floor(pos.xyz);
46 | pos = cc_matProj * pos;
47 | #else
48 | pos = cc_matViewProj * pos;
49 | #endif
50 |
51 | uv0 = a_texCoord;
52 | color = a_color;
53 |
54 | return pos;
55 | }
56 | }%
57 |
58 | CCProgram sprite-fs %{
59 | precision highp float;
60 | #include
61 | #include
62 |
63 | in vec4 color;
64 |
65 | #if USE_TEXTURE
66 | in vec2 uv0;
67 | #pragma builtin(local)
68 | layout(set = 2, binding = 10) uniform sampler2D cc_spriteTexture;
69 | #endif
70 |
71 | uniform FragConstants {
72 | float bluramount;
73 | };
74 |
75 | vec4 draw(vec2 uv) {
76 | return CCSampleWithAlphaSeparated(cc_spriteTexture, uv).rgba;
77 | }
78 | float grid(float var, float size) {
79 | return floor(var* size) /size;
80 | }
81 | float rand(vec2 co){
82 | return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
83 | }
84 | vec4 mainImage(out vec4 o)
85 | {
86 | vec2 uv = uv0.xy;
87 | vec4 blurred_image = vec4(0.);
88 | #pragma define repeats 40.
89 | for (float i = 0.; i < repeats; i++) {
90 | vec2 q = vec2(cos(degrees((i / repeats) * 360.)), sin(degrees((i / repeats) * 360.))) * (rand(vec2(i, uv.x + uv.y)) + bluramount);
91 | vec2 uv2 = uv + (q * bluramount);
92 | blurred_image += draw(uv2) / 2.;
93 | q = vec2(cos(degrees((i / repeats) * 360.)), sin(degrees((i / repeats) * 360.))) * (rand(vec2(i + 2., uv.x + uv.y + 24.)) + bluramount);
94 | uv2 = uv + (q * bluramount);
95 | blurred_image += draw(uv2) / 2.;
96 | }
97 | blurred_image /= repeats;
98 | o = vec4(blurred_image);
99 | return o;
100 | }
101 |
102 | vec4 frag () {
103 | vec4 o = vec4(1, 1, 1, 1);
104 | o*=color;
105 | return mainImage(o);
106 | }
107 | }%
108 |
--------------------------------------------------------------------------------
/assets/case/05_gaussBlur/gaussBlur.effect.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.5.9",
3 | "importer": "effect",
4 | "imported": true,
5 | "uuid": "44d1321e-f9a8-4bd0-b225-1978c590483e",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/05_gaussBlur/gaussBlur.mtl:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.Material",
3 | "_name": "",
4 | "_objFlags": 0,
5 | "_native": "",
6 | "_effectAsset": {
7 | "__uuid__": "44d1321e-f9a8-4bd0-b225-1978c590483e"
8 | },
9 | "_techIdx": 0,
10 | "_defines": [
11 | {
12 | "USE_TEXTURE": true
13 | }
14 | ],
15 | "_states": [
16 | {
17 | "rasterizerState": {},
18 | "depthStencilState": {},
19 | "blendState": {
20 | "targets": [
21 | {}
22 | ]
23 | }
24 | }
25 | ],
26 | "_props": [
27 | {}
28 | ]
29 | }
--------------------------------------------------------------------------------
/assets/case/05_gaussBlur/gaussBlur.mtl.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.13",
3 | "importer": "material",
4 | "imported": true,
5 | "uuid": "8bde537c-1b88-47d8-97e3-6da8f83f3b5e",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/05_gaussBlur/gaussBlur.scene.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.39",
3 | "importer": "scene",
4 | "imported": true,
5 | "uuid": "08ceda46-e8ae-48fe-a948-fc4a316368d6",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/05_gaussBlur/gaussBlur.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: yansixing
3 | * @Date: 2019-08-27 16:17:43
4 | * @Github: https://github.com/yansixing
5 | * @LastEditTime: 2021-05-23 17:17:34
6 | */
7 |
8 | import { _decorator, Component, Sprite, Material } from 'cc';
9 | const { ccclass, property,executeInEditMode } = _decorator;
10 |
11 | @ccclass('GaussBlur')
12 | @executeInEditMode
13 | export default class GaussBlur extends Component {
14 | // @property
15 | bluramount: number = 0.03;
16 | img: Sprite | null = null;
17 | material: Material | undefined | null = null;
18 | onLoad() {
19 | //this.img = this.getComponent(cc.Sprite);
20 | //this.material = this.img.getMaterial(0);
21 |
22 | //this.material.effect.setProperty('bluramount', this.bluramount);
23 | //console.log(this.material);
24 | }
25 | }
--------------------------------------------------------------------------------
/assets/case/05_gaussBlur/gaussBlur.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "4.0.23",
3 | "importer": "typescript",
4 | "imported": true,
5 | "uuid": "33fe8cad-aba8-4721-aa3f-21b9057233f5",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "simulateGlobals": []
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/06_waterWave.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.0",
3 | "importer": "directory",
4 | "imported": true,
5 | "uuid": "47994a1c-433d-44e7-9e7f-58c27b5cd1d1",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "compressionType": {},
10 | "isRemoteBundle": {}
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/assets/case/06_waterWave/waterWave.effect:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
2 | CCEffect %{
3 | techniques:
4 | - passes:
5 | - vert: sprite-vs:vert
6 | frag: sprite-fs:frag
7 | depthStencilState:
8 | depthTest: false
9 | depthWrite: false
10 | blendState:
11 | targets:
12 | - blend: true
13 | blendSrc: src_alpha
14 | blendDst: one_minus_src_alpha
15 | blendDstAlpha: one_minus_src_alpha
16 | rasterizerState:
17 | cullMode: none
18 | properties:
19 | alphaThreshold: { value: 0.5 }
20 | map: { value: white }
21 | }%
22 |
23 | CCProgram sprite-vs %{
24 | precision highp float;
25 | #include
26 | #if USE_LOCAL
27 | #include
28 | #endif
29 |
30 | in vec3 a_position;
31 | in vec2 a_texCoord;
32 | in vec4 a_color;
33 |
34 | out vec4 color;
35 | out vec2 uv0;
36 |
37 | vec4 vert () {
38 | vec4 pos = vec4(a_position, 1);
39 |
40 | #if USE_LOCAL
41 | pos = cc_matWorld * pos;
42 | #endif
43 |
44 | #if USE_PIXEL_ALIGNMENT
45 | pos = cc_matView * pos;
46 | pos.xyz = floor(pos.xyz);
47 | pos = cc_matProj * pos;
48 | #else
49 | pos = cc_matViewProj * pos;
50 | #endif
51 |
52 | uv0 = a_texCoord;
53 |
54 | color = a_color;
55 |
56 | return pos;
57 | }
58 | }%
59 |
60 | CCProgram sprite-fs %{
61 | precision highp float;
62 | #include
63 | #include
64 |
65 | in vec4 color;
66 |
67 | #if USE_TEXTURE
68 | in vec2 uv0;
69 | #pragma builtin(local)
70 | layout(set = 2, binding = 10) uniform sampler2D cc_spriteTexture;
71 | uniform sampler2D map;
72 | #endif
73 |
74 | uniform FragConstants {
75 | float u_time;
76 | };
77 |
78 | vec4 frag () {
79 | vec4 t_map = CCSampleWithAlphaSeparated(map, fract(uv0 + u_time));
80 | float offset = t_map.g;
81 | float scaleX = 0.02;
82 | float scaleY = 0.02;
83 |
84 | vec2 uv = vec2(
85 | uv0.x + offset * scaleX,
86 | uv0.y + offset * scaleY
87 | );
88 |
89 | vec4 t_image = CCSampleWithAlphaSeparated(cc_spriteTexture, uv);
90 |
91 | return t_image;
92 | }
93 | }%
--------------------------------------------------------------------------------
/assets/case/06_waterWave/waterWave.effect.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.5.9",
3 | "importer": "effect",
4 | "imported": true,
5 | "uuid": "7aa79f54-4105-45eb-b80a-e7276c2bd418",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/06_waterWave/waterWave.mtl:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.Material",
3 | "_name": "",
4 | "_objFlags": 0,
5 | "_native": "",
6 | "_effectAsset": {
7 | "__uuid__": "7aa79f54-4105-45eb-b80a-e7276c2bd418"
8 | },
9 | "_techIdx": 0,
10 | "_defines": [
11 | {
12 | "USE_TEXTURE": true
13 | }
14 | ],
15 | "_states": [
16 | {
17 | "rasterizerState": {},
18 | "depthStencilState": {},
19 | "blendState": {
20 | "targets": [
21 | {}
22 | ]
23 | }
24 | }
25 | ],
26 | "_props": [
27 | {
28 | "map": {
29 | "__uuid__": "1aff0a52-c699-49af-a118-fd044138ee1b@6c48a"
30 | }
31 | }
32 | ]
33 | }
--------------------------------------------------------------------------------
/assets/case/06_waterWave/waterWave.mtl.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.13",
3 | "importer": "material",
4 | "imported": true,
5 | "uuid": "85e0fd98-4766-4974-bfbc-eed272c8dbf5",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/06_waterWave/waterWave.scene.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.39",
3 | "importer": "scene",
4 | "imported": true,
5 | "uuid": "2508b828-707a-4804-accc-6ad136e68c67",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/06_waterWave/waterWave.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: yansixing
3 | * @Date: 2019-08-27 16:17:43
4 | * @Github: https://github.com/yansixing
5 | * @LastEditTime: 2021-05-23 19:30:10
6 | */
7 |
8 | import { _decorator, Component, SpriteFrame, Sprite, Material } from 'cc';
9 | const { ccclass, property, executeInEditMode } = _decorator;
10 |
11 | @ccclass('WaterWave')
12 | @executeInEditMode
13 | export default class WaterWave extends Component {
14 | @property(SpriteFrame)
15 | map: SpriteFrame | null = null;
16 | // @property
17 | bluramount: number = 0.03;
18 | img: Sprite | null = null;
19 | material: Material | undefined | null = null;
20 | time: number = 0;
21 | startTime: number = Date.now();
22 | resolution = { x: 0.0, y: 0.0 };
23 | onLoad() {
24 |
25 | this.img = this.getComponent(Sprite);
26 | this.material = this.img?.sharedMaterial;
27 |
28 | // let mapCCSampleWithAlphaSeparated = this.map?.texture.getGFXSampler;
29 | // this.material?.setProperty("map", mapCCSampleWithAlphaSeparated as any);
30 | //this.material = this.img.getMaterial(0);
31 | // let mapCCSampleWithAlphaSeparated = this.map.getTexture().getImpl();
32 | //console.log(mapCCSampleWithAlphaSeparated);
33 | // this.material.effect["_passes"][0]["_properties"]["texture"]["value"] = mapCCSampleWithAlphaSeparated;
34 | // this.material["_effect"]["_properties"]["map"]["value"] = mapCCSampleWithAlphaSeparated;
35 |
36 | console.log(this.material);
37 | }
38 | update() {
39 | this.time = (Date.now() - this.startTime) / 1000;
40 | this.material?.setProperty('u_time', this.time);
41 |
42 | }
43 | }
44 |
45 | /**
46 | * 注意:已把原脚本注释,由于脚本变动过大,转换的时候可能有遗落,需要自行手动转换
47 | */
48 | // /*
49 | // * @Author: yansixing
50 | // * @Date: 2019-08-27 16:17:43
51 | // * @Github: https://github.com/yansixing
52 | // * @LastEditTime: 2020-08-04 09:31:42
53 | // */
54 | //
55 | // const { ccclass, property, executeInEditMode } = cc._decorator;
56 | //
57 | // @ccclass
58 | // @executeInEditMode
59 | // export default class waterWave extends cc.Component {
60 | //
61 | // @property(cc.SpriteFrame)
62 | // map: cc.SpriteFrame = null;
63 | //
64 | // // @property
65 | // bluramount: number = 0.03;
66 | //
67 | // img: cc.Sprite = null;
68 | // material: cc.Material;
69 | // time: number = 0;
70 | // startTime: number = Date.now();
71 | // resolution = { x: 0.0, y: 0.0 };
72 | //
73 | // onLoad() {
74 | //
75 | // this.img = this.getComponent(cc.Sprite);
76 | // this.material = this.img.getMaterial(0);
77 | // let mapCCSampleWithAlphaSeparated = this.map.getTexture().getImpl();
78 | // console.log(mapCCSampleWithAlphaSeparated);
79 | // // this.material.effect["_passes"][0]["_properties"]["texture"]["value"] = mapCCSampleWithAlphaSeparated;
80 | // // this.material["_effect"]["_properties"]["map"]["value"] = mapCCSampleWithAlphaSeparated;
81 | //
82 | // console.log(this.material);
83 | // }
84 | //
85 | // update() {
86 | // this.time = (Date.now() - this.startTime) / 1000;
87 | // this.material.effect.setProperty('u_time', this.time);
88 | //
89 | // }
90 | //
91 | //
92 | // }
93 |
--------------------------------------------------------------------------------
/assets/case/06_waterWave/waterWave.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "4.0.23",
3 | "importer": "typescript",
4 | "imported": true,
5 | "uuid": "f4d52837-ac7b-4518-bbac-70a3d1707db0",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "simulateGlobals": []
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/07_waterRipple.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.0",
3 | "importer": "directory",
4 | "imported": true,
5 | "uuid": "ac599976-e860-43c4-87ac-4a5357271f1f",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "compressionType": {},
10 | "isRemoteBundle": {}
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/assets/case/07_waterRipple/waterRipple.effect:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
2 | CCEffect %{
3 | techniques:
4 | - passes:
5 | - vert: sprite-vs:vert
6 | frag: sprite-fs:frag
7 | depthStencilState:
8 | depthTest: false
9 | depthWrite: false
10 | blendState:
11 | targets:
12 | - blend: true
13 | blendSrc: src_alpha
14 | blendDst: one_minus_src_alpha
15 | blendDstAlpha: one_minus_src_alpha
16 | rasterizerState:
17 | cullMode: none
18 | properties:
19 | alphaThreshold: { value: 0.5 }
20 | center: { value: [0, 0] }
21 | u_time: {value: 0 }
22 | progress: { value: 0 }
23 | aspect: { value: 0 }
24 | radius: { value: 0 }
25 | life: { value: 0 }
26 | band: { value: 0 }
27 | amp: { value: 0 }
28 | waves: { value: 0 }
29 | speed: { value: 0 }
30 | }%
31 |
32 | CCProgram sprite-vs %{
33 | precision highp float;
34 | #include
35 | #if USE_LOCAL
36 | #include
37 | #endif
38 |
39 | in vec3 a_position;
40 | in vec2 a_texCoord;
41 | in vec4 a_color;
42 |
43 | out vec4 color;
44 | out vec2 uv0;
45 |
46 | vec4 vert () {
47 | vec4 pos = vec4(a_position, 1);
48 |
49 | #if USE_LOCAL
50 | pos = cc_matWorld * pos;
51 | #endif
52 |
53 | #if USE_PIXEL_ALIGNMENT
54 | pos = cc_matView * pos;
55 | pos.xyz = floor(pos.xyz);
56 | pos = cc_matProj * pos;
57 | #else
58 | pos = cc_matViewProj * pos;
59 | #endif
60 |
61 | uv0 = a_texCoord;
62 |
63 | color = a_color;
64 |
65 | return pos;
66 | }
67 | }%
68 |
69 | CCProgram sprite-fs %{
70 | precision highp float;
71 | #include
72 | #include
73 |
74 | #pragma define MAX_NUMBER 4
75 |
76 | in vec4 color;
77 |
78 | #if USE_TEXTURE
79 | in vec2 uv0;
80 | #pragma builtin(local)
81 | layout(set = 2, binding = 10) uniform sampler2D cc_spriteTexture;
82 | #endif
83 |
84 | uniform FragConstants {
85 | vec2 center;
86 | float u_time;
87 | float aspect;
88 | float life;
89 | float radius;
90 | float amp;
91 | float band;
92 | float waves;
93 | float speed;
94 | float progress;
95 | };
96 |
97 | vec4 frag () {
98 | vec2 tc = uv0;
99 | vec2 uv = vec2(0.0, 0.0);
100 | vec2 p;
101 | float len;
102 | vec2 uv_offset;
103 | float wave_width = band * radius;
104 |
105 | p = (tc - center);
106 | p.x = p.x * aspect;
107 | len = length(p);
108 |
109 | float current_progress = progress / life;
110 | if (current_progress > 1.0) {
111 | vec4 t_image = CCSampleWithAlphaSeparated(cc_spriteTexture,uv0);
112 | return t_image;
113 | }
114 |
115 | float current_radius = radius * current_progress;
116 | float damp_factor = 1.0;
117 | if (current_progress > .5) {
118 | damp_factor = (1.0 - current_progress) * 2.0;
119 | }
120 |
121 | float cut_factor = clamp(wave_width * damp_factor - abs(current_radius - len), 0.0, 1.0);
122 | float waves_factor = waves * len / radius;
123 | uv_offset = (p / len) * cos((waves_factor - current_progress * speed) * 3.14) * amp * cut_factor;
124 |
125 | uv += uv_offset;
126 |
127 | vec4 t_image = CCSampleWithAlphaSeparated(cc_spriteTexture, fract(tc + uv));
128 |
129 | return t_image;
130 | }
131 | }%
132 |
--------------------------------------------------------------------------------
/assets/case/07_waterRipple/waterRipple.effect.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.5.9",
3 | "importer": "effect",
4 | "imported": true,
5 | "uuid": "acfac1d9-a26a-43e7-a572-15b74289a7d3",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/07_waterRipple/waterRipple.mtl:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.Material",
3 | "_name": "",
4 | "_objFlags": 0,
5 | "_native": "",
6 | "_effectAsset": {
7 | "__uuid__": "acfac1d9-a26a-43e7-a572-15b74289a7d3"
8 | },
9 | "_techIdx": 0,
10 | "_defines": [
11 | {
12 | "USE_TEXTURE": true
13 | }
14 | ],
15 | "_states": [
16 | {
17 | "rasterizerState": {},
18 | "depthStencilState": {},
19 | "blendState": {
20 | "targets": [
21 | {}
22 | ]
23 | }
24 | }
25 | ],
26 | "_props": [
27 | {}
28 | ]
29 | }
--------------------------------------------------------------------------------
/assets/case/07_waterRipple/waterRipple.mtl.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.13",
3 | "importer": "material",
4 | "imported": true,
5 | "uuid": "4cfd0a54-cacd-42c6-bd00-3a9fc5ff787d",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/07_waterRipple/waterRipple.scene.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.39",
3 | "importer": "scene",
4 | "imported": true,
5 | "uuid": "0bb5c249-17c5-43cf-82a0-1984c24b8236",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/07_waterRipple/waterRipple.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: yansixing
3 | * @Date: 2019-09-28 11:26:29
4 | * @Github: https://github.com/yansixing
5 | * @LastEditTime: 2021-05-23 20:35:55
6 | */
7 |
8 | import { _decorator, Component, Sprite, Material, Event, EventTouch, Node, UITransform, Vec3, Vec2 } from 'cc';
9 | const { ccclass, property, executeInEditMode } = _decorator;
10 |
11 | @ccclass('WaterRipple')
12 | @executeInEditMode
13 | export default class WaterRipple extends Component {
14 | aspect: number = 2;
15 | radius: number = 0.6;
16 | life: number = 1.0;
17 | band: number = 0.3;
18 | amp: number = 0.3;
19 | waves: number = 12.0;
20 | speed: number = 2.0;
21 | img: Sprite | null = null;
22 | material: Material | undefined | null = null;
23 | time: number = 1;
24 | uiTransform: UITransform | undefined | null = null;
25 | onLoad() {
26 |
27 | this.node.on(Node.EventType.TOUCH_START, this.onTouchEnd, this);
28 |
29 | this.img = this.getComponent(Sprite);
30 | this.material = this.img?.sharedMaterial;
31 |
32 | this.uiTransform = this.img?.getComponent(UITransform);
33 | if (this.uiTransform) {
34 | this.aspect = this.uiTransform?.width / this.uiTransform?.height;
35 | }
36 | this.material?.setProperty('aspect', this.aspect);
37 | this.material?.setProperty('radius', this.radius);
38 | this.material?.setProperty('life', this.life);
39 | this.material?.setProperty('band', this.band);
40 | this.material?.setProperty('amp', this.amp);
41 | this.material?.setProperty('waves', this.waves);
42 | this.material?.setProperty('speed', this.speed);
43 | this.material?.setProperty('progress', 1.0);
44 |
45 | console.log(this.material);
46 | }
47 | onTouchEnd(evt: EventTouch) {
48 | let touch = evt.getUILocation();
49 | // let local = this.node.convertToNodeSpaceAR(touch);
50 | let local = this.uiTransform?.convertToNodeSpaceAR(new Vec3(touch.x, touch.y, 0));
51 | if (local && this.uiTransform) {
52 | let normalizedPos = new Vec2(local.x / this.uiTransform.width + 0.5, -(local.y / this.uiTransform.height - 0.5));
53 | this.material?.setProperty('center', normalizedPos);
54 | this.material?.setProperty('progress', 0.0);
55 | }
56 | }
57 | update(dt: number) {
58 | this.time += dt;
59 | this.material?.setProperty('u_time', this.time);
60 | let progress = this.material?.getProperty('progress');
61 | if (progress >= 1) {
62 | this.material?.setProperty('progress', -1);
63 | } else if (progress >= 0) {
64 | progress += dt / this.life;
65 | this.material?.setProperty('progress', progress);
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/assets/case/07_waterRipple/waterRipple.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "4.0.23",
3 | "importer": "typescript",
4 | "imported": true,
5 | "uuid": "c7f46c0b-5837-4b2b-a3c1-276068af18d5",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "simulateGlobals": []
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/08_radius.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.0",
3 | "importer": "directory",
4 | "imported": true,
5 | "uuid": "49d882b2-4229-4968-80b8-78c1292cd3e2",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "compressionType": {},
10 | "isRemoteBundle": {}
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/assets/case/08_radius/radius.effect:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
2 | CCEffect %{
3 | techniques:
4 | - passes:
5 | - vert: sprite-vs:vert
6 | frag: sprite-fs:frag
7 | depthStencilState:
8 | depthTest: false
9 | depthWrite: false
10 | blendState:
11 | targets:
12 | - blend: true
13 | blendSrc: src_alpha
14 | blendDst: one_minus_src_alpha
15 | blendDstAlpha: one_minus_src_alpha
16 | rasterizerState:
17 | cullMode: none
18 | properties:
19 | alphaThreshold: { value: 0.5 }
20 | u_edge: { value: 0.2 }
21 | }%
22 |
23 | CCProgram sprite-vs %{
24 | precision highp float;
25 | #include
26 | #if USE_LOCAL
27 | #include
28 | #endif
29 |
30 | in vec3 a_position;
31 | in vec2 a_texCoord;
32 | in vec4 a_color;
33 |
34 | out vec4 color;
35 | out vec2 uv0;
36 |
37 | vec4 vert () {
38 | vec4 pos = vec4(a_position, 1);
39 |
40 | #if USE_LOCAL
41 | pos = cc_matWorld * pos;
42 | #endif
43 |
44 | #if USE_PIXEL_ALIGNMENT
45 | pos = cc_matView * pos;
46 | pos.xyz = floor(pos.xyz);
47 | pos = cc_matProj * pos;
48 | #else
49 | pos = cc_matViewProj * pos;
50 | #endif
51 |
52 | uv0 = a_texCoord;
53 |
54 | color = a_color;
55 |
56 | return pos;
57 | }
58 | }%
59 |
60 | CCProgram sprite-fs %{
61 | precision highp float;
62 | #include
63 | #include
64 |
65 | in vec4 color;
66 |
67 | #if USE_TEXTURE
68 | in vec2 uv0;
69 | #pragma builtin(local)
70 | layout(set = 2, binding = 10) uniform sampler2D cc_spriteTexture;
71 | #endif
72 |
73 | uniform FragConstants {
74 | float u_edge;
75 | };
76 |
77 | vec4 frag () {
78 | vec4 o = vec4(1, 1, 1, 1);
79 |
80 | #if USE_TEXTURE
81 | o *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0);
82 | #endif
83 |
84 | float edge = u_edge;
85 | vec2 uv = uv0.xy - vec2(0.5, 0.5);
86 | float rx = abs(uv.x) - (0.5 - edge);
87 | float ry = abs(uv.y) - (0.5 - edge);
88 | float mx = step(0.5 - edge, abs(uv.x));
89 | float my = step(0.5 - edge, abs(uv.y));
90 | float radius = length(vec2(rx, ry));
91 | float a = 1.0 - mx * my * step(edge, radius) * smoothstep(0., edge * 0.01, radius - edge);
92 | return vec4(o.rgb, o.a * a);
93 | }
94 | }%
95 |
--------------------------------------------------------------------------------
/assets/case/08_radius/radius.effect.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.5.9",
3 | "importer": "effect",
4 | "imported": true,
5 | "uuid": "117d7627-98aa-44d5-8bc0-87bb4e02d3d0",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/08_radius/radius.mtl:
--------------------------------------------------------------------------------
1 | {
2 | "__type__": "cc.Material",
3 | "_name": "",
4 | "_objFlags": 0,
5 | "_native": "",
6 | "_effectAsset": {
7 | "__uuid__": "117d7627-98aa-44d5-8bc0-87bb4e02d3d0"
8 | },
9 | "_techIdx": 0,
10 | "_defines": [
11 | {
12 | "USE_TEXTURE": true
13 | }
14 | ],
15 | "_states": [
16 | {
17 | "rasterizerState": {},
18 | "depthStencilState": {},
19 | "blendState": {
20 | "targets": [
21 | {}
22 | ]
23 | }
24 | }
25 | ],
26 | "_props": [
27 | {}
28 | ]
29 | }
--------------------------------------------------------------------------------
/assets/case/08_radius/radius.mtl.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.13",
3 | "importer": "material",
4 | "imported": true,
5 | "uuid": "2810a275-7de9-4be6-9981-d7f62b40602a",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/08_radius/radius.scene.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.39",
3 | "importer": "scene",
4 | "imported": true,
5 | "uuid": "05a40883-378e-4d55-be50-929104de63e2",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/case/08_radius/radius.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * @Author: yansixing
3 | * @Date: 2019-09-28 11:26:29
4 | * @Github: https://github.com/yansixing
5 | * @LastEditTime: 2021-05-23 20:41:22
6 | */
7 |
8 | import { _decorator, Component, Sprite, Material } from 'cc';
9 | const { ccclass, property, executeInEditMode } = _decorator;
10 |
11 | @ccclass('Radius')
12 | @executeInEditMode
13 | export default class Radius extends Component {
14 | @property
15 | radius: number = 0.2;
16 | img: Sprite | null = null;
17 | material: Material | undefined | null = null;
18 | time: number = 1;
19 | resolution = { x: 0.0, y: 0.0 };
20 | onLoad() {
21 |
22 | this.img = this.getComponent(Sprite);
23 | this.material = this.img?.sharedMaterial;
24 | this.material?.setProperty('u_edge', this.radius);
25 |
26 | console.log(this.material);
27 | }
28 | }
--------------------------------------------------------------------------------
/assets/case/08_radius/radius.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "4.0.23",
3 | "importer": "typescript",
4 | "imported": true,
5 | "uuid": "77b66162-5ce0-4ab7-8890-d132c884c8f9",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "simulateGlobals": []
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/assets/migrate-resources.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.0",
3 | "importer": "directory",
4 | "imported": true,
5 | "uuid": "302c6d0e-9ad4-4e52-b215-f95b5a31aebd",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "compressionType": {},
10 | "isRemoteBundle": {}
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.0",
3 | "importer": "directory",
4 | "imported": true,
5 | "uuid": "a1f46053-740e-443b-bafe-1bdd812e25fb",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "compressionType": {},
10 | "isRemoteBundle": {}
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/cc-lights.chunk:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
2 |
3 |
4 | // TODO: lights uniform should move back to cc-global
5 |
6 | #include
7 | #if CC_SUPPORT_CASCADED_SHADOW_MAP
8 | #include
9 | #endif
10 |
11 | #pragma define CC_MAX_LIGHTS 4
12 |
13 | #if CC_NUM_LIGHTS > 0
14 |
15 | // directional lights
16 | #pragma builtin(global)
17 | uniform CCLIGHTS {
18 | vec4 cc_lightPositionAndRange[CC_MAX_LIGHTS]; // xyz range
19 | vec4 cc_lightDirection[CC_MAX_LIGHTS]; // xyz spotAngle
20 | vec4 cc_lightColor[CC_MAX_LIGHTS]; // xyz spotExp
21 | };
22 |
23 | #endif
24 |
25 | struct LightInfo {
26 | vec3 lightDir;
27 | vec3 radiance;
28 | vec4 lightColor;
29 | };
30 |
31 | // directional light
32 | LightInfo computeDirectionalLighting(
33 | vec4 lightDirection,
34 | vec4 lightColor
35 | ) {
36 | LightInfo ret;
37 | ret.lightDir = -normalize(lightDirection.xyz);
38 | ret.radiance = lightColor.rgb;
39 | ret.lightColor = lightColor;
40 | return ret;
41 | }
42 |
43 | // point light
44 | LightInfo computePointLighting(
45 | vec3 worldPosition,
46 | vec4 lightPositionAndRange,
47 | vec4 lightColor
48 | ) {
49 | LightInfo ret;
50 | vec3 lightDir = lightPositionAndRange.xyz - worldPosition;
51 | float attenuation = max(0., 1.0 - length(lightDir) / lightPositionAndRange.w);
52 |
53 | ret.lightDir = normalize(lightDir);
54 | ret.radiance = lightColor.rgb * attenuation;
55 | ret.lightColor = lightColor;
56 | return ret;
57 | }
58 |
59 | // spot light
60 | LightInfo computeSpotLighting(
61 | vec3 worldPosition,
62 | vec4 lightPositionAndRange,
63 | vec4 lightDirection,
64 | vec4 lightColor
65 | ) {
66 | LightInfo ret;
67 | vec3 lightDir = lightPositionAndRange.xyz - worldPosition;
68 | float attenuation = max(0., 1.0 - length(lightDir) / lightPositionAndRange.w);
69 | lightDir = normalize(lightDir);
70 | float cosConeAngle = max(0., dot(lightDirection.xyz, -lightDir));
71 | cosConeAngle = cosConeAngle < lightDirection.w ? 0. : cosConeAngle;
72 | cosConeAngle = pow(cosConeAngle, lightColor.w);
73 |
74 | ret.lightDir = lightDir;
75 | ret.radiance = lightColor.rgb * attenuation * cosConeAngle;
76 | ret.lightColor = lightColor;
77 | return ret;
78 | }
79 |
80 | struct Lighting {
81 | vec3 diffuse;
82 | vec3 specular;
83 | };
84 |
85 | #pragma define CC_CALC_LIGHT(index, surface, result, lightFunc, ambientFunc) \
86 | #if CC_NUM_LIGHTS > index \
87 | #if CC_LIGHT_##index##_TYPE == 3 \
88 | result.diffuse += ambientFunc(s, cc_lightColor[index]); \
89 | #else \
90 | LightInfo info##index; \
91 | #if CC_LIGHT_##index##_TYPE == 0 \
92 | info##index = computeDirectionalLighting(cc_lightDirection[index], cc_lightColor[index]); \
93 | #elif CC_LIGHT_##index##_TYPE == 1 \
94 | info##index = computePointLighting(s.position, cc_lightPositionAndRange[index], cc_lightColor[index]); \
95 | #elif CC_LIGHT_##index##_TYPE == 2 \
96 | info##index = computeSpotLighting(s.position, cc_lightPositionAndRange[index], cc_lightDirection[index], cc_lightColor[index]); \
97 | #endif \
98 | \
99 | Lighting result##index = lightFunc(surface, info##index); \
100 | CC_CALC_SHADOW(index, result##index) \
101 | result.diffuse += result##index.diffuse; \
102 | result.specular += result##index.specular; \
103 | #endif \
104 | #endif
105 |
106 | #pragma define CC_CALC_LIGHTS(surface, result, lightFunc, ambientFunc) \
107 | result.diffuse = vec3(0, 0, 0); \
108 | result.specular = vec3(0, 0, 0); \
109 | \
110 | CC_CALC_LIGHT(0, surface, result, lightFunc, ambientFunc) \
111 | CC_CALC_LIGHT(1, surface, result, lightFunc, ambientFunc) \
112 | CC_CALC_LIGHT(2, surface, result, lightFunc, ambientFunc) \
113 | CC_CALC_LIGHT(3, surface, result, lightFunc, ambientFunc)
114 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/cc-lights.chunk.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.6",
3 | "importer": "effect-header",
4 | "imported": true,
5 | "uuid": "c8322fea-b8a6-4d2d-8aa4-a59bfceedf10",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {}
9 | }
10 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/decode-base.chunk:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
2 |
3 | #include
4 |
5 | struct StandardVertInput {
6 | highp vec4 position;
7 | vec3 normal;
8 | vec4 tangent;
9 | vec4 color;
10 | vec2 uv;
11 | };
12 |
13 | layout(location = 0) in vec3 a_position;
14 | layout(location = 1) in vec3 a_normal;
15 | layout(location = 2) in vec2 a_texCoord;
16 | layout(location = 3) in vec4 a_tangent;
17 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/decode-base.chunk.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.6",
3 | "importer": "effect-header",
4 | "imported": true,
5 | "uuid": "386bdd52-8a3b-47b2-8efd-af97ee2978de",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {}
9 | }
10 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/phong-fs.chunk:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
2 |
3 | precision highp float;
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | uniform PhongFrag {
11 | lowp vec4 diffuseColor;
12 | lowp vec4 specularColor;
13 | lowp vec4 emissiveColor;
14 | float glossiness;
15 | };
16 |
17 | #if USE_DIFFUSE_TEXTURE
18 | uniform sampler2D diffuseTexture;
19 | #endif
20 |
21 | #if USE_SPECULAR && USE_SPECULAR_TEXTURE
22 | uniform sampler2D specularTexture;
23 | #endif
24 |
25 | #if USE_EMISSIVE && USE_EMISSIVE_TEXTURE
26 | uniform sampler2D emissiveTexture;
27 | #endif
28 |
29 | #if USE_NORMAL_TEXTURE
30 | in vec3 v_tangent;
31 | in vec3 v_bitangent;
32 | uniform sampler2D normalTexture;
33 | #endif
34 |
35 | #pragma define CC_USE_TEXTURE CC_USE_ATTRIBUTE_UV0 && (USE_DIFFUSE_TEXTURE || (USE_EMISSIVE && USE_EMISSIVE_TEXTURE) || (USE_SPECULAR && USE_SPECULAR_TEXTURE) || USE_NORMAL_TEXTURE)
36 |
37 | in vec3 v_worldNormal;
38 | in vec3 v_worldPos;
39 | in vec3 v_viewDirection;
40 |
41 | #if CC_USE_TEXTURE
42 | in mediump vec2 uv0;
43 | #endif
44 |
45 | #if CC_USE_ATTRIBUTE_COLOR
46 | in lowp vec4 color;
47 | #endif
48 |
49 | #include
50 |
51 | void surf (out PhongSurface s) {
52 | vec4 diffuse = vec4(1, 1, 1, 1);
53 |
54 | #if CC_USE_ATTRIBUTE_COLOR
55 | diffuse *= color;
56 | #endif
57 |
58 | diffuse *= diffuseColor;
59 | #if USE_DIFFUSE_TEXTURE
60 | CCTexture(diffuseTexture, uv0, diffuse);
61 | #endif
62 |
63 | ALPHA_TEST(diffuse);
64 |
65 | s.diffuse = diffuse.rgb;
66 | s.opacity = diffuse.a;
67 |
68 | #if USE_EMISSIVE
69 | s.emissive = emissiveColor.rgb;
70 | #if USE_EMISSIVE_TEXTURE
71 | CCTextureRGB(emissiveTexture, uv0, s.emissive);
72 | #endif
73 | #endif
74 |
75 | #if USE_SPECULAR
76 | s.specular = specularColor.rgb;
77 | #if USE_SPECULAR_TEXTURE
78 | CCTextureRGB(specularTexture, uv0, s.specular);
79 | #endif
80 | #endif
81 |
82 | s.normal = v_worldNormal;
83 | #if USE_NORMAL_TEXTURE
84 | vec3 nmmp = texture(normalTexture, uv0).xyz - vec3(0.5);
85 | s.normal =
86 | nmmp.x * normalize(v_tangent) +
87 | nmmp.y * normalize(v_bitangent) +
88 | nmmp.z * normalize(s.normal);
89 | s.normal = normalize(s.normal);
90 | #endif
91 |
92 | s.position = v_worldPos;
93 | s.viewDirection = v_viewDirection;
94 | s.glossiness = glossiness;
95 | }
96 |
97 | void main () {
98 | PhongSurface s;
99 | surf(s);
100 | vec4 color = CCPhongShading(s);
101 | gl_FragColor = CCFragOutput(color);
102 | }
103 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/phong-fs.chunk.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.6",
3 | "importer": "effect-header",
4 | "imported": true,
5 | "uuid": "d69eb639-f814-43dc-aef5-24ac5e16967f",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {}
9 | }
10 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/phong-vs.chunk:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
2 |
3 | precision highp float;
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 | #if CC_SUPPORT_CASCADED_SHADOW_MAP
10 | #include
11 | #endif
12 |
13 | #pragma define CC_USE_TEXTURE CC_USE_ATTRIBUTE_UV0 && (USE_DIFFUSE_TEXTURE || USE_EMISSIVE_TEXTURE || USE_SPECULAR_TEXTURE || USE_NORMAL_TEXTURE)
14 |
15 | uniform MAIN_TILING {
16 | vec2 mainTiling;
17 | vec2 mainOffset;
18 | };
19 |
20 | #if CC_USE_TEXTURE
21 | out mediump vec2 uv0;
22 | #endif
23 |
24 | #if CC_USE_ATTRIBUTE_COLOR
25 | out lowp vec4 color;
26 | #endif
27 |
28 | #if USE_NORMAL_TEXTURE
29 | out vec3 v_tangent;
30 | out vec3 v_bitangent;
31 | #endif
32 |
33 | out vec3 v_worldNormal;
34 | out vec3 v_worldPos;
35 | out vec3 v_viewDirection;
36 |
37 | void main () {
38 | StandardVertInput In;
39 | CCVertInput(In);
40 |
41 | vec4 position = In.position;
42 |
43 | v_worldNormal = normalize((cc_matWorldIT * vec4(In.normal, 0)).xyz);
44 | v_worldPos = (cc_matWorld * position).xyz;
45 | v_viewDirection = normalize(cc_cameraPos.xyz - v_worldPos);
46 |
47 | #if CC_USE_TEXTURE
48 | uv0 = In.uv * mainTiling + mainOffset;
49 | #endif
50 |
51 | #if CC_USE_ATTRIBUTE_COLOR
52 | color = In.color;
53 | #endif
54 |
55 | #if USE_NORMAL_TEXTURE
56 | v_tangent = normalize((cc_matWorld * vec4(In.tangent.xyz, 0.0)).xyz);
57 | v_bitangent = cross(v_worldNormal, v_tangent) * In.tangent.w; // note the cross order
58 | #endif
59 |
60 | CCShadowInput(v_worldPos);
61 |
62 | gl_Position = cc_matViewProj * cc_matWorld * position;
63 | }
64 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/phong-vs.chunk.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.6",
3 | "importer": "effect-header",
4 | "imported": true,
5 | "uuid": "adb8ff37-f56a-40b2-8b90-55de189bc47f",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {}
9 | }
10 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/shading-phong.chunk:
--------------------------------------------------------------------------------
1 |
2 | #include
3 |
4 | struct PhongSurface {
5 | vec3 diffuse;
6 | vec3 emissive;
7 | vec3 specular;
8 | float opacity;
9 |
10 | float glossiness;
11 |
12 | vec3 position;
13 | vec3 normal;
14 | vec3 viewDirection;
15 | };
16 |
17 | Lighting brdf (PhongSurface s, LightInfo info) {
18 | Lighting result;
19 | float ndh = 0.0;
20 | // Get the half direction in world space
21 | vec3 halfDir = normalize(s.viewDirection + info.lightDir);
22 | float NdotH = max(0.0, dot(s.normal, halfDir));
23 | NdotH = pow(NdotH, max(1.0, s.glossiness * 128.0));
24 |
25 | result.diffuse = info.radiance * max(0.0, dot(s.normal, info.lightDir));
26 | result.specular = info.radiance * NdotH;
27 |
28 | return result;
29 | }
30 |
31 | vec4 composePhongShading (Lighting lighting, PhongSurface s) {
32 | vec4 o = vec4(0.0, 0.0, 0.0, 1.0);
33 |
34 | //diffuse is always calculated
35 | o.rgb = lighting.diffuse * s.diffuse;
36 |
37 | #if USE_EMISSIVE
38 | o.rgb += s.emissive;
39 | #endif
40 |
41 | #if USE_SPECULAR
42 | o.rgb += lighting.specular * s.specular;
43 | #endif
44 |
45 | o.a = s.opacity;
46 |
47 | return o;
48 | }
49 |
50 | vec3 ambient(PhongSurface s, vec4 ambientColor) {
51 | return s.diffuse * ambientColor.rgb;
52 | }
53 |
54 | vec4 CCPhongShading (in PhongSurface s) {
55 | Lighting result;
56 | CC_CALC_LIGHTS(s, result, brdf, ambient)
57 |
58 | return composePhongShading(result, s);
59 | }
60 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/shading-phong.chunk.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.6",
3 | "importer": "effect-header",
4 | "imported": true,
5 | "uuid": "d5de0f60-a664-4ce7-ab78-49f4e05dc076",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {}
9 | }
10 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/shading-toon.chunk:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2019 Xiamen Yaji Software Co., Ltd.
2 | #include
3 | #include
4 |
5 | struct ToonSurface {
6 | vec4 baseColor;
7 | // specular
8 | vec3 specular;
9 | float specularThreshold;
10 | // these need to be in the same coordinate system
11 | vec3 position;
12 | vec3 normal;
13 | vec3 viewDirection;
14 | // emissive
15 | vec3 emissive;
16 | // shadow
17 | vec3 shadowColor;
18 | float shadowIntensity;
19 | vec3 highlightColor;
20 | // light
21 | float lightThreshold;
22 | float lightSmoothness;
23 | };
24 |
25 | const float T_H = 0.25;
26 | float TreshHoldLighting(float lThreshold, float smoothness, float v) {
27 | return smoothstep(lThreshold-smoothness*T_H, lThreshold+smoothness*T_H, v);
28 | }
29 |
30 | Lighting toon (ToonSurface s, LightInfo info) {
31 | Lighting result;
32 |
33 | vec3 N = s.normal;
34 | vec3 L = info.lightDir;
35 | vec3 V = s.viewDirection;
36 | vec3 H = normalize(L + V);
37 | float NL = 0.5 * dot(N, L) + 0.5;
38 | float NH = 0.5 * dot(H, N) + 0.5;
39 |
40 | vec3 c = vec3(0.0);
41 |
42 | vec3 attenuation = info.radiance;
43 | vec3 lightColor = info.lightColor.rgb;
44 |
45 | // diffuse
46 | vec3 shadowColor = mix(s.highlightColor * lightColor, s.shadowColor, s.shadowIntensity);
47 | vec3 diffuse = TreshHoldLighting(s.lightThreshold, s.lightSmoothness, NL) * attenuation;
48 | diffuse = mix(shadowColor, s.highlightColor * lightColor, diffuse);
49 |
50 | result.diffuse = diffuse * s.baseColor.rgb;
51 |
52 | // specular
53 | float specularWeight = 1.0 - pow(s.specularThreshold, 5.0);
54 | float specularMask = step(specularWeight, NH);
55 | vec3 specular = s.specular.rgb * specularMask;
56 |
57 | result.specular = specular * attenuation;
58 |
59 | return result;
60 | }
61 |
62 | vec3 ambient(ToonSurface s, vec4 ambientColor) {
63 | return s.baseColor.rgb * ambientColor.rgb;
64 | }
65 |
66 | vec4 CCToonShading (ToonSurface s) {
67 | Lighting result;
68 | CC_CALC_LIGHTS(s, result, toon, ambient)
69 |
70 | vec3 finalColor = result.diffuse + result.specular + s.emissive;
71 | return vec4(finalColor, s.baseColor.a);
72 | }
73 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/shading-toon.chunk.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.6",
3 | "importer": "effect-header",
4 | "imported": true,
5 | "uuid": "82b494d7-a706-466d-8557-d297bffc5c9d",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {}
9 | }
10 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/texture.chunk:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #pragma define CCTexture(_texture_, _uv_, _color_) \
4 | vec4 _texture_##_tmp = texture(_texture_, _uv_); \
5 | #if CC_USE_EMBEDDED_ALPHA \
6 | _texture_##_tmp.a *= texture(_texture_, _uv_ + vec2(0, 0.5)).r; \
7 | #endif \
8 | #if INPUT_IS_GAMMA \
9 | _color_.rgb *= SRGBToLinear(_texture_##_tmp.rgb); \
10 | _color_.a *= _texture_##_tmp.a; \
11 | #else \
12 | _color_ *= _texture_##_tmp; \
13 | #endif \
14 | #pragma // empty pragma trick to get rid of trailing semicolons at effect compile time
15 |
16 | #pragma define CCTextureRGB(_texture_, _uv_, _color_) \
17 | vec4 _texture_##_tmp = texture(_texture_, _uv_); \
18 | #if CC_USE_EMBEDDED_ALPHA \
19 | _texture_##_tmp.a *= texture(_texture_, _uv_ + vec2(0, 0.5)).r; \
20 | #endif \
21 | #if INPUT_IS_GAMMA \
22 | _color_.rgb *= SRGBToLinear(_texture_##_tmp.rgb); \
23 | #else \
24 | _color_.rgb *= _texture_##_tmp.rgb; \
25 | #endif \
26 | #pragma // empty pragma trick to get rid of trailing semicolons at effect compile time
27 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/texture.chunk.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.6",
3 | "importer": "effect-header",
4 | "imported": true,
5 | "uuid": "c8397c15-cb15-4a3f-9c24-849af3d84498",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {}
9 | }
10 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/unlit-fs.chunk:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
2 |
3 | precision highp float;
4 |
5 | #include
6 | #include
7 | #include
8 |
9 | uniform UNLIT {
10 | lowp vec4 diffuseColor;
11 | };
12 |
13 | #if USE_DIFFUSE_TEXTURE
14 | uniform sampler2D diffuseTexture;
15 | #endif
16 |
17 | #pragma define CC_USE_TEXTURE CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE
18 |
19 | #if CC_USE_ATTRIBUTE_COLOR
20 | in lowp vec4 color;
21 | #endif
22 |
23 | #if CC_USE_TEXTURE
24 | in mediump vec2 uv0;
25 | #endif
26 |
27 | void main () {
28 | vec4 color = diffuseColor;
29 |
30 | #if CC_USE_TEXTURE
31 | CCTexture(diffuseTexture, uv0, color);
32 | #endif
33 |
34 | #if CC_USE_ATTRIBUTE_COLOR
35 | color *= color;
36 | #endif
37 |
38 | ALPHA_TEST(color);
39 |
40 | gl_FragColor = CCFragOutput(color);
41 | }
42 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/unlit-fs.chunk.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.6",
3 | "importer": "effect-header",
4 | "imported": true,
5 | "uuid": "23629fb1-c0e7-4300-8036-399701725717",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {}
9 | }
10 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/unlit-vs.chunk:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
2 |
3 | precision highp float;
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | #pragma define CC_USE_TEXTURE CC_USE_ATTRIBUTE_UV0 && USE_DIFFUSE_TEXTURE
11 |
12 | uniform MAIN_TILING {
13 | vec2 mainTiling;
14 | vec2 mainOffset;
15 | };
16 |
17 | #if CC_USE_TEXTURE
18 | out mediump vec2 uv0;
19 | #endif
20 |
21 | #if CC_USE_ATTRIBUTE_COLOR
22 | out lowp vec4 color;
23 | #endif
24 |
25 | void main () {
26 | StandardVertInput In;
27 | CCVertInput(In);
28 |
29 | #if CC_USE_ATTRIBUTE_COLOR
30 | color = In.color;
31 | #endif
32 |
33 | #if CC_USE_TEXTURE
34 | uv0 = In.uv * mainTiling + mainOffset;
35 | #endif
36 |
37 | gl_Position = cc_matViewProj * cc_matWorld * In.position;
38 | }
39 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/unlit-vs.chunk.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.6",
3 | "importer": "effect-header",
4 | "imported": true,
5 | "uuid": "9e84ad2c-12ef-48a4-8ba2-4955b9aeabf7",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {}
9 | }
10 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/unpack.chunk:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
2 |
3 | vec3 unpackNormal(vec4 nmap) {
4 | return nmap.xyz * 2.0 - 1.0;
5 | }
6 |
7 | vec3 unpackRGBE(vec4 rgbe) {
8 | return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);
9 | }
10 |
--------------------------------------------------------------------------------
/assets/migrate-resources/chunks/unpack.chunk.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.6",
3 | "importer": "effect-header",
4 | "imported": true,
5 | "uuid": "deb66d97-8cee-47fe-ab79-6fb983fe0fc5",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {}
9 | }
10 |
--------------------------------------------------------------------------------
/assets/scene.scene:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "__type__": "cc.SceneAsset",
4 | "_name": "",
5 | "_objFlags": 0,
6 | "_native": "",
7 | "scene": {
8 | "__id__": 1
9 | },
10 | "asyncLoadAssets": false
11 | },
12 | {
13 | "__type__": "cc.Scene",
14 | "_name": "",
15 | "_objFlags": 0,
16 | "_parent": null,
17 | "_children": [
18 | {
19 | "__id__": 2
20 | },
21 | {
22 | "__id__": 5
23 | },
24 | {
25 | "__id__": 7
26 | },
27 | {
28 | "__id__": 11
29 | }
30 | ],
31 | "_active": true,
32 | "_components": [],
33 | "_prefab": {
34 | "__id__": 20
35 | },
36 | "autoReleaseAssets": false,
37 | "_globals": {
38 | "__id__": 15
39 | },
40 | "_id": "f46876e4-e81b-4931-b493-6d367be385e7"
41 | },
42 | {
43 | "__type__": "cc.Node",
44 | "_name": "Main Light",
45 | "_objFlags": 0,
46 | "_parent": {
47 | "__id__": 1
48 | },
49 | "_children": [],
50 | "_active": true,
51 | "_components": [
52 | {
53 | "__id__": 3
54 | }
55 | ],
56 | "_prefab": null,
57 | "_lpos": {
58 | "__type__": "cc.Vec3",
59 | "x": -21.071,
60 | "y": 24.331,
61 | "z": 36.496
62 | },
63 | "_lrot": {
64 | "__type__": "cc.Quat",
65 | "x": -0.24999999999999997,
66 | "y": -0.24999999999999997,
67 | "z": -0.06698729810778066,
68 | "w": 0.9330127018922194
69 | },
70 | "_lscale": {
71 | "__type__": "cc.Vec3",
72 | "x": 1,
73 | "y": 1,
74 | "z": 1
75 | },
76 | "_layer": 1073741824,
77 | "_euler": {
78 | "__type__": "cc.Vec3",
79 | "x": -30,
80 | "y": -30,
81 | "z": 0
82 | },
83 | "_id": "c0y6F5f+pAvI805TdmxIjx"
84 | },
85 | {
86 | "__type__": "cc.DirectionalLight",
87 | "_name": "",
88 | "_objFlags": 0,
89 | "node": {
90 | "__id__": 2
91 | },
92 | "_enabled": true,
93 | "__prefab": null,
94 | "_color": {
95 | "__type__": "cc.Color",
96 | "r": 255,
97 | "g": 255,
98 | "b": 255,
99 | "a": 255
100 | },
101 | "_useColorTemperature": false,
102 | "_colorTemperature": 6550,
103 | "_staticSettings": {
104 | "__id__": 4
105 | },
106 | "_illuminance": 65000,
107 | "_id": "597uMYCbhEtJQc0ffJlcgA",
108 | "_illuminanceLDR": 1.6927083333333335,
109 | "_illuminanceHDR": 65000,
110 | "_shadowEnabled": true,
111 | "_shadowPcf": 0,
112 | "_shadowBias": 0.1,
113 | "_shadowNormalBias": 0,
114 | "_shadowSaturation": 1,
115 | "_shadowDistance": 100,
116 | "_shadowInvisibleOcclusionRange": 200,
117 | "_shadowFixedArea": false,
118 | "_shadowNear": 1,
119 | "_shadowFar": 30,
120 | "_shadowOrthoSize": 5,
121 | "_csmLevel": 1,
122 | "_csmLayerLambda": 0.75,
123 | "_csmOptimizationMode": 2
124 | },
125 | {
126 | "__type__": "cc.StaticLightSettings",
127 | "_baked": false,
128 | "_editorOnly": false,
129 | "_bakeable": false,
130 | "_castShadow": false
131 | },
132 | {
133 | "__type__": "cc.Node",
134 | "_name": "Main Camera",
135 | "_objFlags": 0,
136 | "_parent": {
137 | "__id__": 1
138 | },
139 | "_children": [],
140 | "_active": true,
141 | "_components": [
142 | {
143 | "__id__": 6
144 | }
145 | ],
146 | "_prefab": null,
147 | "_lpos": {
148 | "__type__": "cc.Vec3",
149 | "x": -10,
150 | "y": 10,
151 | "z": 10
152 | },
153 | "_lrot": {
154 | "__type__": "cc.Quat",
155 | "x": -0.27781593346944056,
156 | "y": -0.36497167621709875,
157 | "z": -0.11507512748638377,
158 | "w": 0.8811195706053617
159 | },
160 | "_lscale": {
161 | "__type__": "cc.Vec3",
162 | "x": 1,
163 | "y": 1,
164 | "z": 1
165 | },
166 | "_layer": 1073741824,
167 | "_euler": {
168 | "__type__": "cc.Vec3",
169 | "x": -35,
170 | "y": -45,
171 | "z": 0
172 | },
173 | "_id": "c9DMICJLFO5IeO07EPon7U"
174 | },
175 | {
176 | "__type__": "cc.Camera",
177 | "_name": "",
178 | "_objFlags": 0,
179 | "node": {
180 | "__id__": 5
181 | },
182 | "_enabled": true,
183 | "__prefab": null,
184 | "_projection": 1,
185 | "_priority": 0,
186 | "_fov": 45,
187 | "_fovAxis": 0,
188 | "_orthoHeight": 10,
189 | "_near": 1,
190 | "_far": 1000,
191 | "_color": {
192 | "__type__": "cc.Color",
193 | "r": 51,
194 | "g": 51,
195 | "b": 51,
196 | "a": 255
197 | },
198 | "_depth": 1,
199 | "_stencil": 0,
200 | "_clearFlags": 7,
201 | "_rect": {
202 | "__type__": "cc.Rect",
203 | "x": 0,
204 | "y": 0,
205 | "width": 1,
206 | "height": 1
207 | },
208 | "_aperture": 19,
209 | "_shutter": 7,
210 | "_iso": 0,
211 | "_screenScale": 1,
212 | "_visibility": 1822425087,
213 | "_targetTexture": null,
214 | "_id": "7dWQTpwS5LrIHnc1zAPUtf"
215 | },
216 | {
217 | "__type__": "cc.Node",
218 | "_name": "Plane",
219 | "_objFlags": 0,
220 | "_parent": {
221 | "__id__": 1
222 | },
223 | "_children": [],
224 | "_active": true,
225 | "_components": [
226 | {
227 | "__id__": 8
228 | }
229 | ],
230 | "_prefab": null,
231 | "_lpos": {
232 | "__type__": "cc.Vec3",
233 | "x": 0,
234 | "y": 0,
235 | "z": 0
236 | },
237 | "_lrot": {
238 | "__type__": "cc.Quat",
239 | "x": 0,
240 | "y": 0,
241 | "z": 0,
242 | "w": 1
243 | },
244 | "_lscale": {
245 | "__type__": "cc.Vec3",
246 | "x": 1,
247 | "y": 1,
248 | "z": 1
249 | },
250 | "_layer": 1073741824,
251 | "_euler": {
252 | "__type__": "cc.Vec3",
253 | "x": 0,
254 | "y": 0,
255 | "z": 0
256 | },
257 | "_id": "9eHyM09WNHkL6qP/B0BIkY"
258 | },
259 | {
260 | "__type__": "cc.MeshRenderer",
261 | "_name": "Plane",
262 | "_objFlags": 0,
263 | "node": {
264 | "__id__": 7
265 | },
266 | "_enabled": true,
267 | "__prefab": {
268 | "__id__": 9
269 | },
270 | "_materials": [
271 | {
272 | "__uuid__": "d3c7820c-2a98-4429-8bc7-b8453bc9ac41"
273 | }
274 | ],
275 | "_visFlags": 0,
276 | "lightmapSettings": {
277 | "__id__": 10
278 | },
279 | "_mesh": {
280 | "__uuid__": "1263d74c-8167-4928-91a6-4e2672411f47@2e76e"
281 | },
282 | "_shadowCastingMode": 0,
283 | "_shadowReceivingMode": 1,
284 | "_enableMorph": true,
285 | "_id": "41OIA7MBZBwKd3rey5lUHV"
286 | },
287 | {
288 | "__type__": "cc.CompPrefabInfo",
289 | "fileId": "e0uHCYkZ1D1I9glcT6oLf2"
290 | },
291 | {
292 | "__type__": "cc.ModelLightmapSettings",
293 | "texture": null,
294 | "uvParam": {
295 | "__type__": "cc.Vec4",
296 | "x": 0,
297 | "y": 0,
298 | "z": 0,
299 | "w": 0
300 | },
301 | "_bakeable": false,
302 | "_castShadow": false,
303 | "_receiveShadow": false,
304 | "_recieveShadow": false,
305 | "_lightmapSize": 64
306 | },
307 | {
308 | "__type__": "cc.Node",
309 | "_name": "Cube",
310 | "_objFlags": 0,
311 | "_parent": {
312 | "__id__": 1
313 | },
314 | "_children": [],
315 | "_active": true,
316 | "_components": [
317 | {
318 | "__id__": 12
319 | }
320 | ],
321 | "_prefab": null,
322 | "_lpos": {
323 | "__type__": "cc.Vec3",
324 | "x": 0,
325 | "y": 0.5,
326 | "z": 0
327 | },
328 | "_lrot": {
329 | "__type__": "cc.Quat",
330 | "x": 0,
331 | "y": 0,
332 | "z": 0,
333 | "w": 1
334 | },
335 | "_lscale": {
336 | "__type__": "cc.Vec3",
337 | "x": 1,
338 | "y": 1,
339 | "z": 1
340 | },
341 | "_layer": 1073741824,
342 | "_euler": {
343 | "__type__": "cc.Vec3",
344 | "x": 0,
345 | "y": 0,
346 | "z": 0
347 | },
348 | "_id": "47Gry5jNNLZIHabdwzuNQN"
349 | },
350 | {
351 | "__type__": "cc.MeshRenderer",
352 | "_name": "Cube",
353 | "_objFlags": 0,
354 | "node": {
355 | "__id__": 11
356 | },
357 | "_enabled": true,
358 | "__prefab": {
359 | "__id__": 13
360 | },
361 | "_materials": [
362 | {
363 | "__uuid__": "d3c7820c-2a98-4429-8bc7-b8453bc9ac41"
364 | }
365 | ],
366 | "_visFlags": 0,
367 | "lightmapSettings": {
368 | "__id__": 14
369 | },
370 | "_mesh": {
371 | "__uuid__": "1263d74c-8167-4928-91a6-4e2672411f47@a804a"
372 | },
373 | "_shadowCastingMode": 1,
374 | "_shadowReceivingMode": 1,
375 | "_enableMorph": true,
376 | "_id": "1apUaRE6dB6akesmIivVpx"
377 | },
378 | {
379 | "__type__": "cc.CompPrefabInfo",
380 | "fileId": "e8DOT5UJ1F/ZgplWYyCxRs"
381 | },
382 | {
383 | "__type__": "cc.ModelLightmapSettings",
384 | "texture": null,
385 | "uvParam": {
386 | "__type__": "cc.Vec4",
387 | "x": 0,
388 | "y": 0,
389 | "z": 0,
390 | "w": 0
391 | },
392 | "_bakeable": false,
393 | "_castShadow": false,
394 | "_receiveShadow": false,
395 | "_recieveShadow": false,
396 | "_lightmapSize": 64
397 | },
398 | {
399 | "__type__": "cc.SceneGlobals",
400 | "ambient": {
401 | "__id__": 16
402 | },
403 | "shadows": {
404 | "__id__": 17
405 | },
406 | "_skybox": {
407 | "__id__": 18
408 | },
409 | "fog": {
410 | "__id__": 19
411 | }
412 | },
413 | {
414 | "__type__": "cc.AmbientInfo",
415 | "_skyColor": {
416 | "__type__": "cc.Vec4",
417 | "x": 0.2,
418 | "y": 0.5019607843137255,
419 | "z": 0.8,
420 | "w": 0.520833125
421 | },
422 | "_skyIllum": 20000,
423 | "_groundAlbedo": {
424 | "__type__": "cc.Vec4",
425 | "x": 0.2,
426 | "y": 0.2,
427 | "z": 0.2,
428 | "w": 1
429 | },
430 | "_skyColorLDR": {
431 | "__type__": "cc.Vec4",
432 | "x": 0.2,
433 | "y": 0.5019607843137255,
434 | "z": 0.8,
435 | "w": 0.520833125
436 | },
437 | "_skyColorHDR": {
438 | "__type__": "cc.Vec4",
439 | "x": 0.2,
440 | "y": 0.5019607843137255,
441 | "z": 0.8,
442 | "w": 0.520833125
443 | },
444 | "_groundAlbedoLDR": {
445 | "__type__": "cc.Vec4",
446 | "x": 0.2,
447 | "y": 0.2,
448 | "z": 0.2,
449 | "w": 1
450 | },
451 | "_groundAlbedoHDR": {
452 | "__type__": "cc.Vec4",
453 | "x": 0.2,
454 | "y": 0.2,
455 | "z": 0.2,
456 | "w": 1
457 | },
458 | "_skyIllumLDR": 0.78125,
459 | "_skyIllumHDR": 20000
460 | },
461 | {
462 | "__type__": "cc.ShadowsInfo",
463 | "_type": 0,
464 | "_enabled": true,
465 | "_normal": {
466 | "__type__": "cc.Vec3",
467 | "x": 0,
468 | "y": 1,
469 | "z": 0
470 | },
471 | "_distance": 0,
472 | "_shadowColor": {
473 | "__type__": "cc.Color",
474 | "r": 76,
475 | "g": 76,
476 | "b": 76,
477 | "a": 255
478 | },
479 | "_maxReceived": 4,
480 | "_size": {
481 | "__type__": "cc.Vec2",
482 | "x": 512,
483 | "y": 512
484 | }
485 | },
486 | {
487 | "__type__": "cc.SkyboxInfo",
488 | "_envmap": null,
489 | "_enabled": false,
490 | "_useHDR": true,
491 | "_envmapLDR": null,
492 | "_envmapHDR": null,
493 | "_diffuseMapLDR": null,
494 | "_diffuseMapHDR": null,
495 | "_envLightingType": 0
496 | },
497 | {
498 | "__type__": "cc.FogInfo",
499 | "_type": 0,
500 | "_fogColor": {
501 | "__type__": "cc.Color",
502 | "r": 225,
503 | "g": 225,
504 | "b": 225,
505 | "a": 255
506 | },
507 | "_enabled": false,
508 | "_fogDensity": 0.3,
509 | "_fogStart": 0.5,
510 | "_fogEnd": 300,
511 | "_fogAtten": 5,
512 | "_fogTop": 1.5,
513 | "_fogRange": 1.2,
514 | "_accurate": false
515 | },
516 | {
517 | "__type__": "cc.PrefabInfo",
518 | "fileId": "f46876e4-e81b-4931-b493-6d367be385e7"
519 | }
520 | ]
--------------------------------------------------------------------------------
/assets/scene.scene.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.39",
3 | "importer": "scene",
4 | "imported": true,
5 | "uuid": "683e7461-87c0-43bf-afa4-4109176dea95",
6 | "files": [
7 | ".json"
8 | ],
9 | "subMetas": {},
10 | "userData": {}
11 | }
12 |
--------------------------------------------------------------------------------
/assets/texture.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.0",
3 | "importer": "directory",
4 | "imported": true,
5 | "uuid": "bdcf8258-8a34-4cc6-b0bc-a9d0757ab42d",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "compressionType": {},
10 | "isRemoteBundle": {}
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/assets/texture/Fort_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yansixing/cocos-shader-demo/2b7dca2ad14a560ae78c286591cb9e6a6cab9497/assets/texture/Fort_1.png
--------------------------------------------------------------------------------
/assets/texture/Fort_1.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.24",
3 | "importer": "image",
4 | "imported": true,
5 | "uuid": "e6579a13-a7d6-4b16-8587-a60a9a4a7fa0",
6 | "files": [
7 | ".json",
8 | ".png"
9 | ],
10 | "subMetas": {
11 | "6c48a": {
12 | "importer": "texture",
13 | "uuid": "e6579a13-a7d6-4b16-8587-a60a9a4a7fa0@6c48a",
14 | "displayName": "Fort_1",
15 | "id": "6c48a",
16 | "name": "texture",
17 | "userData": {
18 | "minfilter": "linear",
19 | "magfilter": "linear",
20 | "wrapModeT": "clamp-to-edge",
21 | "wrapModeS": "clamp-to-edge",
22 | "mipfilter": "none",
23 | "imageUuidOrDatabaseUri": "e6579a13-a7d6-4b16-8587-a60a9a4a7fa0",
24 | "anisotropy": 0,
25 | "isUuid": true,
26 | "visible": false
27 | },
28 | "ver": "1.0.22",
29 | "imported": true,
30 | "files": [
31 | ".json"
32 | ],
33 | "subMetas": {}
34 | },
35 | "f9941": {
36 | "importer": "sprite-frame",
37 | "uuid": "e6579a13-a7d6-4b16-8587-a60a9a4a7fa0@f9941",
38 | "displayName": "Fort_1",
39 | "id": "f9941",
40 | "name": "spriteFrame",
41 | "userData": {
42 | "trimType": "custom",
43 | "trimThreshold": 0,
44 | "rotated": false,
45 | "offsetX": 0,
46 | "offsetY": 0,
47 | "trimX": 0,
48 | "trimY": 0,
49 | "width": 72,
50 | "height": 100,
51 | "rawWidth": 72,
52 | "rawHeight": 100,
53 | "borderTop": 0,
54 | "borderBottom": 0,
55 | "borderLeft": 0,
56 | "borderRight": 0,
57 | "imageUuidOrDatabaseUri": "e6579a13-a7d6-4b16-8587-a60a9a4a7fa0@6c48a",
58 | "packable": false,
59 | "isUuid": true,
60 | "atlasUuid": "",
61 | "pixelsToUnit": 100,
62 | "pivotX": 0.5,
63 | "pivotY": 0.5,
64 | "meshType": 0,
65 | "vertices": {
66 | "rawPosition": [
67 | -36,
68 | -50,
69 | 0,
70 | 36,
71 | -50,
72 | 0,
73 | -36,
74 | 50,
75 | 0,
76 | 36,
77 | 50,
78 | 0
79 | ],
80 | "indexes": [
81 | 0,
82 | 1,
83 | 2,
84 | 2,
85 | 1,
86 | 3
87 | ],
88 | "uv": [
89 | 0,
90 | 100,
91 | 72,
92 | 100,
93 | 0,
94 | 0,
95 | 72,
96 | 0
97 | ],
98 | "nuv": [
99 | 0,
100 | 0,
101 | 1,
102 | 0,
103 | 0,
104 | 1,
105 | 1,
106 | 1
107 | ],
108 | "minPos": [
109 | -36,
110 | -50,
111 | 0
112 | ],
113 | "maxPos": [
114 | 36,
115 | 50,
116 | 0
117 | ]
118 | }
119 | },
120 | "ver": "1.0.11",
121 | "imported": true,
122 | "files": [
123 | ".json"
124 | ],
125 | "subMetas": {}
126 | }
127 | },
128 | "userData": {
129 | "type": "sprite-frame",
130 | "hasAlpha": true,
131 | "redirect": "e6579a13-a7d6-4b16-8587-a60a9a4a7fa0@f9941",
132 | "fixAlphaTransparencyArtifacts": false
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/assets/texture/Fort_60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yansixing/cocos-shader-demo/2b7dca2ad14a560ae78c286591cb9e6a6cab9497/assets/texture/Fort_60.png
--------------------------------------------------------------------------------
/assets/texture/Fort_60.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.24",
3 | "importer": "image",
4 | "imported": true,
5 | "uuid": "94b5e528-a7f6-4b07-95a0-7fca2598ebd3",
6 | "files": [
7 | ".json",
8 | ".png"
9 | ],
10 | "subMetas": {
11 | "6c48a": {
12 | "importer": "texture",
13 | "uuid": "94b5e528-a7f6-4b07-95a0-7fca2598ebd3@6c48a",
14 | "displayName": "Fort_60",
15 | "id": "6c48a",
16 | "name": "texture",
17 | "userData": {
18 | "minfilter": "linear",
19 | "magfilter": "linear",
20 | "wrapModeT": "clamp-to-edge",
21 | "wrapModeS": "clamp-to-edge",
22 | "mipfilter": "none",
23 | "imageUuidOrDatabaseUri": "94b5e528-a7f6-4b07-95a0-7fca2598ebd3",
24 | "anisotropy": 0,
25 | "isUuid": true,
26 | "visible": false
27 | },
28 | "ver": "1.0.22",
29 | "imported": true,
30 | "files": [
31 | ".json"
32 | ],
33 | "subMetas": {}
34 | },
35 | "f9941": {
36 | "importer": "sprite-frame",
37 | "uuid": "94b5e528-a7f6-4b07-95a0-7fca2598ebd3@f9941",
38 | "displayName": "Fort_60",
39 | "id": "f9941",
40 | "name": "spriteFrame",
41 | "userData": {
42 | "trimType": "auto",
43 | "trimThreshold": 0,
44 | "rotated": false,
45 | "offsetX": 0,
46 | "offsetY": 0,
47 | "trimX": 0,
48 | "trimY": 0,
49 | "width": 128,
50 | "height": 115,
51 | "rawWidth": 128,
52 | "rawHeight": 115,
53 | "borderTop": 0,
54 | "borderBottom": 0,
55 | "borderLeft": 0,
56 | "borderRight": 0,
57 | "imageUuidOrDatabaseUri": "94b5e528-a7f6-4b07-95a0-7fca2598ebd3@6c48a",
58 | "packable": false,
59 | "isUuid": true,
60 | "atlasUuid": "",
61 | "pixelsToUnit": 100,
62 | "pivotX": 0.5,
63 | "pivotY": 0.5,
64 | "meshType": 0,
65 | "vertices": {
66 | "rawPosition": [
67 | -64,
68 | -57.5,
69 | 0,
70 | 64,
71 | -57.5,
72 | 0,
73 | -64,
74 | 57.5,
75 | 0,
76 | 64,
77 | 57.5,
78 | 0
79 | ],
80 | "indexes": [
81 | 0,
82 | 1,
83 | 2,
84 | 2,
85 | 1,
86 | 3
87 | ],
88 | "uv": [
89 | 0,
90 | 115,
91 | 128,
92 | 115,
93 | 0,
94 | 0,
95 | 128,
96 | 0
97 | ],
98 | "nuv": [
99 | 0,
100 | 0,
101 | 1,
102 | 0,
103 | 0,
104 | 1,
105 | 1,
106 | 1
107 | ],
108 | "minPos": [
109 | -64,
110 | -57.5,
111 | 0
112 | ],
113 | "maxPos": [
114 | 64,
115 | 57.5,
116 | 0
117 | ]
118 | }
119 | },
120 | "ver": "1.0.11",
121 | "imported": true,
122 | "files": [
123 | ".json"
124 | ],
125 | "subMetas": {}
126 | }
127 | },
128 | "userData": {
129 | "type": "sprite-frame",
130 | "hasAlpha": true,
131 | "redirect": "94b5e528-a7f6-4b07-95a0-7fca2598ebd3@f9941",
132 | "fixAlphaTransparencyArtifacts": false
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/assets/texture/gun-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yansixing/cocos-shader-demo/2b7dca2ad14a560ae78c286591cb9e6a6cab9497/assets/texture/gun-1.png
--------------------------------------------------------------------------------
/assets/texture/gun-1.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.24",
3 | "importer": "image",
4 | "imported": true,
5 | "uuid": "b99ff1e7-ac1e-4e2c-80a9-b0ae8fccab8a",
6 | "files": [
7 | ".json",
8 | ".png"
9 | ],
10 | "subMetas": {
11 | "6c48a": {
12 | "importer": "texture",
13 | "uuid": "b99ff1e7-ac1e-4e2c-80a9-b0ae8fccab8a@6c48a",
14 | "displayName": "gun-1",
15 | "id": "6c48a",
16 | "name": "texture",
17 | "userData": {
18 | "minfilter": "linear",
19 | "magfilter": "linear",
20 | "wrapModeT": "clamp-to-edge",
21 | "wrapModeS": "clamp-to-edge",
22 | "mipfilter": "none",
23 | "imageUuidOrDatabaseUri": "b99ff1e7-ac1e-4e2c-80a9-b0ae8fccab8a",
24 | "anisotropy": 0,
25 | "isUuid": true,
26 | "visible": false
27 | },
28 | "ver": "1.0.22",
29 | "imported": true,
30 | "files": [
31 | ".json"
32 | ],
33 | "subMetas": {}
34 | },
35 | "f9941": {
36 | "importer": "sprite-frame",
37 | "uuid": "b99ff1e7-ac1e-4e2c-80a9-b0ae8fccab8a@f9941",
38 | "displayName": "gun-1",
39 | "id": "f9941",
40 | "name": "spriteFrame",
41 | "userData": {
42 | "trimType": "custom",
43 | "trimThreshold": 1,
44 | "rotated": false,
45 | "offsetX": 0,
46 | "offsetY": 0,
47 | "trimX": 0,
48 | "trimY": 0,
49 | "width": 300,
50 | "height": 200,
51 | "rawWidth": 300,
52 | "rawHeight": 200,
53 | "borderTop": 0,
54 | "borderBottom": 0,
55 | "borderLeft": 0,
56 | "borderRight": 0,
57 | "imageUuidOrDatabaseUri": "b99ff1e7-ac1e-4e2c-80a9-b0ae8fccab8a@6c48a",
58 | "packable": false,
59 | "isUuid": true,
60 | "atlasUuid": "",
61 | "pixelsToUnit": 100,
62 | "pivotX": 0.5,
63 | "pivotY": 0.5,
64 | "meshType": 0,
65 | "vertices": {
66 | "rawPosition": [
67 | -150,
68 | -100,
69 | 0,
70 | 150,
71 | -100,
72 | 0,
73 | -150,
74 | 100,
75 | 0,
76 | 150,
77 | 100,
78 | 0
79 | ],
80 | "indexes": [
81 | 0,
82 | 1,
83 | 2,
84 | 2,
85 | 1,
86 | 3
87 | ],
88 | "uv": [
89 | 0,
90 | 200,
91 | 300,
92 | 200,
93 | 0,
94 | 0,
95 | 300,
96 | 0
97 | ],
98 | "nuv": [
99 | 0,
100 | 0,
101 | 1,
102 | 0,
103 | 0,
104 | 1,
105 | 1,
106 | 1
107 | ],
108 | "minPos": [
109 | -150,
110 | -100,
111 | 0
112 | ],
113 | "maxPos": [
114 | 150,
115 | 100,
116 | 0
117 | ]
118 | }
119 | },
120 | "ver": "1.0.11",
121 | "imported": true,
122 | "files": [
123 | ".json"
124 | ],
125 | "subMetas": {}
126 | }
127 | },
128 | "userData": {
129 | "type": "sprite-frame",
130 | "hasAlpha": true,
131 | "redirect": "b99ff1e7-ac1e-4e2c-80a9-b0ae8fccab8a@f9941",
132 | "fixAlphaTransparencyArtifacts": false
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/assets/texture/image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yansixing/cocos-shader-demo/2b7dca2ad14a560ae78c286591cb9e6a6cab9497/assets/texture/image.jpg
--------------------------------------------------------------------------------
/assets/texture/image.jpg.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.24",
3 | "importer": "image",
4 | "imported": true,
5 | "uuid": "3c41424e-dcbd-45b9-83ae-1bd00c5b8f22",
6 | "files": [
7 | ".jpg",
8 | ".json"
9 | ],
10 | "subMetas": {
11 | "6c48a": {
12 | "importer": "texture",
13 | "uuid": "3c41424e-dcbd-45b9-83ae-1bd00c5b8f22@6c48a",
14 | "displayName": "image",
15 | "id": "6c48a",
16 | "name": "texture",
17 | "userData": {
18 | "minfilter": "linear",
19 | "magfilter": "linear",
20 | "wrapModeT": "clamp-to-edge",
21 | "wrapModeS": "clamp-to-edge",
22 | "mipfilter": "none",
23 | "imageUuidOrDatabaseUri": "3c41424e-dcbd-45b9-83ae-1bd00c5b8f22",
24 | "anisotropy": 0,
25 | "isUuid": true,
26 | "visible": false
27 | },
28 | "ver": "1.0.22",
29 | "imported": true,
30 | "files": [
31 | ".json"
32 | ],
33 | "subMetas": {}
34 | },
35 | "f9941": {
36 | "importer": "sprite-frame",
37 | "uuid": "3c41424e-dcbd-45b9-83ae-1bd00c5b8f22@f9941",
38 | "displayName": "image",
39 | "id": "f9941",
40 | "name": "spriteFrame",
41 | "userData": {
42 | "trimType": "custom",
43 | "trimThreshold": 1,
44 | "rotated": false,
45 | "offsetX": 0,
46 | "offsetY": 0,
47 | "trimX": 0,
48 | "trimY": 0,
49 | "width": 2048,
50 | "height": 1024,
51 | "rawWidth": 2048,
52 | "rawHeight": 1024,
53 | "borderTop": 0,
54 | "borderBottom": 0,
55 | "borderLeft": 0,
56 | "borderRight": 0,
57 | "imageUuidOrDatabaseUri": "3c41424e-dcbd-45b9-83ae-1bd00c5b8f22@6c48a",
58 | "packable": false,
59 | "isUuid": true,
60 | "atlasUuid": "",
61 | "pixelsToUnit": 100,
62 | "pivotX": 0.5,
63 | "pivotY": 0.5,
64 | "meshType": 0,
65 | "vertices": {
66 | "rawPosition": [
67 | -1024,
68 | -512,
69 | 0,
70 | 1024,
71 | -512,
72 | 0,
73 | -1024,
74 | 512,
75 | 0,
76 | 1024,
77 | 512,
78 | 0
79 | ],
80 | "indexes": [
81 | 0,
82 | 1,
83 | 2,
84 | 2,
85 | 1,
86 | 3
87 | ],
88 | "uv": [
89 | 0,
90 | 1024,
91 | 2048,
92 | 1024,
93 | 0,
94 | 0,
95 | 2048,
96 | 0
97 | ],
98 | "nuv": [
99 | 0,
100 | 0,
101 | 1,
102 | 0,
103 | 0,
104 | 1,
105 | 1,
106 | 1
107 | ],
108 | "minPos": [
109 | -1024,
110 | -512,
111 | 0
112 | ],
113 | "maxPos": [
114 | 1024,
115 | 512,
116 | 0
117 | ]
118 | }
119 | },
120 | "ver": "1.0.11",
121 | "imported": true,
122 | "files": [
123 | ".json"
124 | ],
125 | "subMetas": {}
126 | }
127 | },
128 | "userData": {
129 | "type": "sprite-frame",
130 | "hasAlpha": false,
131 | "redirect": "3c41424e-dcbd-45b9-83ae-1bd00c5b8f22@f9941",
132 | "fixAlphaTransparencyArtifacts": false
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/assets/texture/img-01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yansixing/cocos-shader-demo/2b7dca2ad14a560ae78c286591cb9e6a6cab9497/assets/texture/img-01.jpg
--------------------------------------------------------------------------------
/assets/texture/img-01.jpg.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.24",
3 | "importer": "image",
4 | "imported": true,
5 | "uuid": "530d0a9f-ee1a-4b85-b306-7b50bf6d5ab5",
6 | "files": [
7 | ".jpg",
8 | ".json"
9 | ],
10 | "subMetas": {
11 | "6c48a": {
12 | "importer": "texture",
13 | "uuid": "530d0a9f-ee1a-4b85-b306-7b50bf6d5ab5@6c48a",
14 | "displayName": "img-01",
15 | "id": "6c48a",
16 | "name": "texture",
17 | "userData": {
18 | "minfilter": "linear",
19 | "magfilter": "linear",
20 | "wrapModeT": "clamp-to-edge",
21 | "wrapModeS": "clamp-to-edge",
22 | "mipfilter": "none",
23 | "imageUuidOrDatabaseUri": "530d0a9f-ee1a-4b85-b306-7b50bf6d5ab5",
24 | "anisotropy": 0,
25 | "isUuid": true,
26 | "visible": false
27 | },
28 | "ver": "1.0.22",
29 | "imported": true,
30 | "files": [
31 | ".json"
32 | ],
33 | "subMetas": {}
34 | },
35 | "f9941": {
36 | "importer": "sprite-frame",
37 | "uuid": "530d0a9f-ee1a-4b85-b306-7b50bf6d5ab5@f9941",
38 | "displayName": "img-01",
39 | "id": "f9941",
40 | "name": "spriteFrame",
41 | "userData": {
42 | "trimType": "custom",
43 | "trimThreshold": 1,
44 | "rotated": false,
45 | "offsetX": 0,
46 | "offsetY": 0,
47 | "trimX": 0,
48 | "trimY": 0,
49 | "width": 1920,
50 | "height": 1080,
51 | "rawWidth": 1920,
52 | "rawHeight": 1080,
53 | "borderTop": 0,
54 | "borderBottom": 0,
55 | "borderLeft": 0,
56 | "borderRight": 0,
57 | "imageUuidOrDatabaseUri": "530d0a9f-ee1a-4b85-b306-7b50bf6d5ab5@6c48a",
58 | "packable": false,
59 | "isUuid": true,
60 | "atlasUuid": "",
61 | "pixelsToUnit": 100,
62 | "pivotX": 0.5,
63 | "pivotY": 0.5,
64 | "meshType": 0,
65 | "vertices": {
66 | "rawPosition": [
67 | -960,
68 | -540,
69 | 0,
70 | 960,
71 | -540,
72 | 0,
73 | -960,
74 | 540,
75 | 0,
76 | 960,
77 | 540,
78 | 0
79 | ],
80 | "indexes": [
81 | 0,
82 | 1,
83 | 2,
84 | 2,
85 | 1,
86 | 3
87 | ],
88 | "uv": [
89 | 0,
90 | 1080,
91 | 1920,
92 | 1080,
93 | 0,
94 | 0,
95 | 1920,
96 | 0
97 | ],
98 | "nuv": [
99 | 0,
100 | 0,
101 | 1,
102 | 0,
103 | 0,
104 | 1,
105 | 1,
106 | 1
107 | ],
108 | "minPos": [
109 | -960,
110 | -540,
111 | 0
112 | ],
113 | "maxPos": [
114 | 960,
115 | 540,
116 | 0
117 | ]
118 | }
119 | },
120 | "ver": "1.0.11",
121 | "imported": true,
122 | "files": [
123 | ".json"
124 | ],
125 | "subMetas": {}
126 | }
127 | },
128 | "userData": {
129 | "type": "sprite-frame",
130 | "hasAlpha": false,
131 | "redirect": "530d0a9f-ee1a-4b85-b306-7b50bf6d5ab5@f9941",
132 | "fixAlphaTransparencyArtifacts": false
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/assets/texture/wave.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yansixing/cocos-shader-demo/2b7dca2ad14a560ae78c286591cb9e6a6cab9497/assets/texture/wave.png
--------------------------------------------------------------------------------
/assets/texture/wave.png.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.0.24",
3 | "importer": "image",
4 | "imported": true,
5 | "uuid": "1aff0a52-c699-49af-a118-fd044138ee1b",
6 | "files": [
7 | ".json",
8 | ".png"
9 | ],
10 | "subMetas": {
11 | "6c48a": {
12 | "importer": "texture",
13 | "uuid": "1aff0a52-c699-49af-a118-fd044138ee1b@6c48a",
14 | "displayName": "wave",
15 | "id": "6c48a",
16 | "name": "texture",
17 | "userData": {
18 | "minfilter": "linear",
19 | "magfilter": "linear",
20 | "wrapModeT": "clamp-to-edge",
21 | "wrapModeS": "clamp-to-edge",
22 | "mipfilter": "none",
23 | "imageUuidOrDatabaseUri": "1aff0a52-c699-49af-a118-fd044138ee1b",
24 | "anisotropy": 0,
25 | "isUuid": true,
26 | "visible": false
27 | },
28 | "ver": "1.0.22",
29 | "imported": true,
30 | "files": [
31 | ".json"
32 | ],
33 | "subMetas": {}
34 | },
35 | "f9941": {
36 | "importer": "sprite-frame",
37 | "uuid": "1aff0a52-c699-49af-a118-fd044138ee1b@f9941",
38 | "displayName": "wave",
39 | "id": "f9941",
40 | "name": "spriteFrame",
41 | "userData": {
42 | "trimType": "custom",
43 | "trimThreshold": 1,
44 | "rotated": false,
45 | "offsetX": 0,
46 | "offsetY": 0,
47 | "trimX": 0,
48 | "trimY": 0,
49 | "width": 256,
50 | "height": 256,
51 | "rawWidth": 256,
52 | "rawHeight": 256,
53 | "borderTop": 0,
54 | "borderBottom": 0,
55 | "borderLeft": 0,
56 | "borderRight": 0,
57 | "imageUuidOrDatabaseUri": "1aff0a52-c699-49af-a118-fd044138ee1b@6c48a",
58 | "packable": false,
59 | "isUuid": true,
60 | "atlasUuid": "",
61 | "pixelsToUnit": 100,
62 | "pivotX": 0.5,
63 | "pivotY": 0.5,
64 | "meshType": 0,
65 | "vertices": {
66 | "rawPosition": [
67 | -128,
68 | -128,
69 | 0,
70 | 128,
71 | -128,
72 | 0,
73 | -128,
74 | 128,
75 | 0,
76 | 128,
77 | 128,
78 | 0
79 | ],
80 | "indexes": [
81 | 0,
82 | 1,
83 | 2,
84 | 2,
85 | 1,
86 | 3
87 | ],
88 | "uv": [
89 | 0,
90 | 256,
91 | 256,
92 | 256,
93 | 0,
94 | 0,
95 | 256,
96 | 0
97 | ],
98 | "nuv": [
99 | 0,
100 | 0,
101 | 1,
102 | 0,
103 | 0,
104 | 1,
105 | 1,
106 | 1
107 | ],
108 | "minPos": [
109 | -128,
110 | -128,
111 | 0
112 | ],
113 | "maxPos": [
114 | 128,
115 | 128,
116 | 0
117 | ]
118 | }
119 | },
120 | "ver": "1.0.11",
121 | "imported": true,
122 | "files": [
123 | ".json"
124 | ],
125 | "subMetas": {}
126 | }
127 | },
128 | "userData": {
129 | "type": "sprite-frame",
130 | "hasAlpha": false,
131 | "redirect": "1aff0a52-c699-49af-a118-fd044138ee1b@f9941",
132 | "fixAlphaTransparencyArtifacts": false
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/assets/utils.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "1.1.0",
3 | "importer": "directory",
4 | "imported": true,
5 | "uuid": "1994a1a9-49fd-4f66-9d21-252b00e79bb3",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "compressionType": {},
10 | "isRemoteBundle": {}
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/assets/utils/cocosHack.ts:
--------------------------------------------------------------------------------
1 | // window.onblur = function () {
2 | // cc.game.pause();
3 | // }
4 | // window.onfocus = function () {
5 | // cc.game.resume();
6 | // }
7 |
8 | import { _decorator } from 'cc';
9 | (() => {
10 | })()
11 |
12 | /**
13 | * 注意:已把原脚本注释,由于脚本变动过大,转换的时候可能有遗落,需要自行手动转换
14 | */
15 | // (() => {
16 | // // window.onblur = function () {
17 | // // cc.game.pause();
18 | // // }
19 | // // window.onfocus = function () {
20 | // // cc.game.resume();
21 | // // }
22 | // })()
23 |
--------------------------------------------------------------------------------
/assets/utils/cocosHack.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "4.0.23",
3 | "importer": "typescript",
4 | "imported": true,
5 | "uuid": "c66b4f1d-7321-4785-a182-77605e343f3d",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "simulateGlobals": []
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/assets/utils/utils.ts:
--------------------------------------------------------------------------------
1 | // let max = base * (1 + range);
2 | // export function numberOfOccurencesInArr(names: any[]) {
3 | // let countedNames = names.reduce(function (allNames, name) {
4 | // if (name in allNames) {
5 | // allNames[name + ""]++;
6 | // }
7 | // else {
8 | // allNames[name + ""] = 1;
9 | // }
10 | // return allNames;
11 | // }, {});
12 | // return countedNames;
13 | // }
14 | // export function randomInArr(arr: T[], weightArr?: number[]) {
15 | // return arr[randomInt(0, arr.length)];
16 | // }
17 | // export function loadPrefab(url: string) {
18 | // return new Promise(resolve => {
19 | // cc.loader2.loadRes(url, cc.Asset, (e, res: cc.Prefab) => {
20 | // resolve(res);
21 | // });
22 | // })
23 | // }
24 | // export function getOrLoadPrefab(url: string) {
25 | // return new Promise(resolve => {
26 | // let ret = cc.loader2.getRes(url);
27 | // if (ret) {
28 | // resolve(ret);
29 | // } else {
30 | // cc.loader2.loadRes(url, cc.Asset, (e, res: cc.Prefab) => {
31 | // resolve(res);
32 | // });
33 | // }
34 | // })
35 | // }
36 | // export function getOrLoadRes(url: string) {
37 | // return new Promise(resolve => {
38 | // let ret = cc.loader2.getRes(url);
39 | // if (ret) {
40 | // resolve(ret);
41 | // } else {
42 | // cc.loader2.loadRes(url, cc.Asset, (e, res) => {
43 | // resolve(res);
44 | // });
45 | // }
46 | // })
47 | // }
48 | // export function getOrLoadTexture(url: string, callback: (tex: cc.CCSampleWithAlphaSeparated) => void) {
49 | // let tex = cc.loader2.getRes(url) as cc.CCSampleWithAlphaSeparated
50 | // if (tex) {
51 | // callback(tex);
52 | // return;
53 | // }
54 | // cc.loader2.loadRes(url, cc.Asset, undefined, (e: Error, tex: cc.CCSampleWithAlphaSeparated) => {
55 | // callback(tex);
56 | // });
57 | // }
58 |
59 | import { _decorator, loader, Asset, rencesInArr, Vec2, log, Prefab } from 'cc';
60 | export namespace Utils {
61 | export function getOrLoadRes(url: string) {
62 | return new Promise(resolve => {
63 | let ret = loader.getRes(url);
64 | if (ret) {
65 | resolve(ret);
66 | } else {
67 | cc.loader.loadRes(url, Asset, (e, res) => {
68 | resolve(res);
69 | });
70 | }
71 | })
72 | }
73 | export function getRandomInRange(base: number, range: number) {
74 | let min = base * (1 - range);
75 | return min + Math.random() * base * range * 2;
76 | }
77 | export function posOfOrencesInArr(names: any[]): { [k: string]: number[] } {
78 | let countedNames = names.reduce(function (allNames, name, index) {
79 | if (name in allNames) {
80 | allNames[name + ""].push(index);
81 | }
82 | else {
83 | allNames[name + ""] = [index];
84 | }
85 | return allNames;
86 | }, {});
87 | return countedNames;
88 | }
89 | export function angleToNormalizeVec(angle: number): Vec2 {
90 | let vec = new Vec2();
91 | let arc = angle * Math.PI / 180;
92 | vec.x = Math.cos(arc);
93 | vec.y = Math.sin(arc);
94 | return vec;
95 | }
96 | export function swapTwoInArr(index1: number, index2: number, arr: any[]) {
97 | [arr[index1], arr[index2]] = [arr[index2], arr[index1]];
98 | return arr;
99 | }
100 | export function clamp(v: number, min: number, max: number) {
101 | return v > max ? max : v < min ? min : v
102 | }
103 | export function lerp(v: number, from: number, to: number) {
104 | return from + (to - from) * v;
105 | }
106 | export function mod(v: number, m: number) {
107 | while (v < 0) v += m;
108 | return v % m;
109 | }
110 | export function randomInt(min: number, max: number) {
111 | return (Math.random() * (max - min) | 0) + min;
112 | }
113 | export function randomRange(min: number, max: number) {
114 | return Math.random() * (max - min) + min;
115 | }
116 | export function randomInArr(arr: T[], weightArr?: number[]) {
117 | if (!weightArr) {
118 | return arr[randomInt(0, arr.length)];
119 | } else {
120 | if (arr.length !== weightArr.length) {
121 | console.log("Unequal length!");
122 | return;
123 | }
124 | let item;
125 | let sum = 0;
126 | weightArr.forEach(function (value) {
127 | sum += value;
128 | })
129 | let randomFloat = Math.random() * sum;
130 | sum = 0;
131 | for (let i = 0; i < weightArr.length; i++) {
132 | sum += weightArr[i];
133 | if (randomFloat < sum) {
134 | item = arr[i];
135 | break;
136 | }
137 | }
138 | return item;
139 | }
140 | }
141 | export function randomTwoInArr(arr: T[]) {
142 | let arr2 = makeArrayRandom(arr);
143 | return arr2.slice(0, 2);
144 | }
145 | export function makeArrayRandom(arr: T[]) {
146 | for (let i = 0; i < arr.length; ++i) {
147 | let j = (arr.length * Math.random()) | 0;
148 | if (i != j)
149 | [arr[i], arr[j]] = [arr[j], arr[i]];
150 | }
151 | return arr;
152 | }
153 | export function isInRange(v: number, min: number, max: number) {
154 | return v >= min && v <= max;
155 | }
156 | export function setColorMatrix(colorMatrix: number[], hex: number) {
157 | let result = Utils.hexToRGB(hex);
158 | colorMatrix[0] = result.r / 255;
159 | colorMatrix[6] = result.g / 255;
160 | colorMatrix[12] = result.b / 255;
161 | return colorMatrix;
162 | }
163 | export function newColorMatrix(hex: number) {
164 | let c = Utils.hexToRGB(hex);
165 | return [
166 | c.r / 255, 0, 0, 0, 0,
167 | 0, c.g / 255, 0, 0, 0,
168 | 0, 0, c.b / 255, 0, 0,
169 | 0, 0, 0, 1, 0,
170 | ];
171 | }
172 | export function hexToRGB(hex: number) {
173 | return {
174 | b: hex & 0xff,
175 | g: hex >> 8 & 0xff,
176 | r: hex >> 16 & 0xff
177 | }
178 | }
179 | export function pad(num: number, n: number) {
180 | return (Array(n).join("0") + num).slice(-n);
181 | }
182 | export function arrayToSet(arr: T[]) {
183 | let set: T[] = [];
184 | for (let i = 0; i < arr.length; ++i) {
185 | set.includes(arr[i]) || set.push(arr[i]);
186 | }
187 | return set;
188 | }
189 | export function getMaxInArray(arr: number[]) {
190 | let max = NaN;
191 | for (let i = 0; i < arr.length; ++i) {
192 | if (isNaN(max) || arr[i] > max) {
193 | max = arr[i];
194 | }
195 | }
196 | return max;
197 | }
198 | export function randomItemsFromArray(amount: number, arr: T[]) {
199 | return makeArrayRandom(arr.concat()).slice(0, amount)
200 | }
201 | export const deepClone = obj => JSON.parse(JSON.stringify(obj));
202 | export function wait(duration, callBack?) {
203 | return new Promise((resolve, reject) => {
204 | setTimeout(() => {
205 | if (callBack) callBack();
206 | resolve();
207 | }, duration)
208 | });
209 | }
210 | export function callLater(callback: () => void, time = 0) {
211 | setTimeout(callback, time)
212 | }
213 | export function removeByValue(arr: any[], val: any) {
214 | for (var i = 0; i < arr.length; i++) {
215 | if (arr[i] == val) {
216 | arr.splice(i, 1);
217 | break;
218 | }
219 | }
220 | }
221 | let _log = log;
222 | export function removeLog() {
223 | if (Context.isFB) {
224 | log = () => { };
225 | }
226 | }
227 | export function recoverLog() {
228 | if (Context.isFB) {
229 | log = _log;
230 | }
231 | }
232 | export function formatHMS(v: number) {
233 | if (v < 0) return;
234 | let h = Math.floor(v / 3600) + "";
235 | let m = Math.floor((v % 3600) / 60) + "";
236 | let s = Math.floor(v % 60) + "";
237 | return [h, m, s].map(str => str.length < 2 ? "0" + str : str).join(":");
238 | }
239 | export function formatMS(v: number) {
240 | if (v < 0) return;
241 | let m = Math.floor((v % 3600) / 60) + "";
242 | let s = Math.floor((v % 3600) % 60) + "";
243 | return [m, s].map(str => str.length < 2 ? "0" + str : str).join(":");
244 | }
245 | export function loadPrefab(url: string) {
246 | return new Promise(resolve => {
247 | cc.loader.loadRes(url, cc.Asset, (e, res: Prefab) => {
248 | resolve(res);
249 | });
250 | })
251 | }
252 | export function getRandomName() {
253 | let arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
254 | let ret: string[] = [];
255 | for (let i = 0; i < 8; ++i) {
256 | ret.push(randomInArr(arr));
257 | }
258 | return "Gardener_" + ret.join("");
259 | }
260 | }
261 |
262 | /**
263 | * 注意:已把原脚本注释,由于脚本变动过大,转换的时候可能有遗落,需要自行手动转换
264 | */
265 | // export namespace Utils {
266 | //
267 | // export function getOrLoadRes(url: string) {
268 | // return new Promise(resolve => {
269 | // let ret = cc.loader.getRes(url);
270 | // if (ret) {
271 | // resolve(ret);
272 | // } else {
273 | // cc.loader.loadRes(url, cc.Asset, (e, res) => {
274 | // resolve(res);
275 | // });
276 | // }
277 | // })
278 | // }
279 | //
280 | // export function getRandomInRange(base: number, range: number) {
281 | // let min = base * (1 - range);
282 | // // let max = base * (1 + range);
283 | // return min + Math.random() * base * range * 2;
284 | // }
285 | //
286 | // // export function numberOfOccurencesInArr(names: any[]) {
287 | // // let countedNames = names.reduce(function (allNames, name) {
288 | // // if (name in allNames) {
289 | // // allNames[name + ""]++;
290 | // // }
291 | // // else {
292 | // // allNames[name + ""] = 1;
293 | // // }
294 | // // return allNames;
295 | // // }, {});
296 | // // return countedNames;
297 | // // }
298 | //
299 | // export function posOfOccurencesInArr(names: any[]): { [k: string]: number[] } {
300 | // let countedNames = names.reduce(function (allNames, name, index) {
301 | // if (name in allNames) {
302 | // allNames[name + ""].push(index);
303 | // }
304 | // else {
305 | // allNames[name + ""] = [index];
306 | // }
307 | // return allNames;
308 | // }, {});
309 | // return countedNames;
310 | // }
311 | // export function angleToNormalizeVec(angle: number): cc.Vec2 {
312 | // let vec = new cc.Vec2();
313 | // let arc = angle * Math.PI / 180;
314 | // vec.x = Math.cos(arc);
315 | // vec.y = Math.sin(arc);
316 | // return vec;
317 | // }
318 | //
319 | // export function swapTwoInArr(index1: number, index2: number, arr: any[]) {
320 | // [arr[index1], arr[index2]] = [arr[index2], arr[index1]];
321 | // return arr;
322 | // }
323 | //
324 | // export function clamp(v: number, min: number, max: number) {
325 | // return v > max ? max : v < min ? min : v
326 | // }
327 | //
328 | // export function lerp(v: number, from: number, to: number) {
329 | // return from + (to - from) * v;
330 | // }
331 | //
332 | // export function mod(v: number, m: number) {
333 | // while (v < 0) v += m;
334 | // return v % m;
335 | // }
336 | //
337 | // export function randomInt(min: number, max: number) {
338 | // return (Math.random() * (max - min) | 0) + min;
339 | // }
340 | //
341 | // export function randomRange(min: number, max: number) {
342 | // return Math.random() * (max - min) + min;
343 | // }
344 | //
345 | // // export function randomInArr(arr: T[], weightArr?: number[]) {
346 | // // return arr[randomInt(0, arr.length)];
347 | // // }
348 | // export function randomInArr(arr: T[], weightArr?: number[]) {
349 | // if (!weightArr) {
350 | // return arr[randomInt(0, arr.length)];
351 | // } else {
352 | // if (arr.length !== weightArr.length) {
353 | // console.log("Unequal length!");
354 | // return;
355 | // }
356 | // let item;
357 | // let sum = 0;
358 | // weightArr.forEach(function (value) {
359 | // sum += value;
360 | // })
361 | // let randomFloat = Math.random() * sum;
362 | // sum = 0;
363 | // for (let i = 0; i < weightArr.length; i++) {
364 | // sum += weightArr[i];
365 | // if (randomFloat < sum) {
366 | // item = arr[i];
367 | // break;
368 | // }
369 | // }
370 | // return item;
371 | // }
372 | // }
373 | //
374 | // export function randomTwoInArr(arr: T[]) {
375 | // let arr2 = makeArrayRandom(arr);
376 | // return arr2.slice(0, 2);
377 | // }
378 | //
379 | // export function makeArrayRandom(arr: T[]) {
380 | // for (let i = 0; i < arr.length; ++i) {
381 | // let j = (arr.length * Math.random()) | 0;
382 | // if (i != j)
383 | // [arr[i], arr[j]] = [arr[j], arr[i]];
384 | // }
385 | // return arr;
386 | // }
387 | //
388 | // export function isInRange(v: number, min: number, max: number) {
389 | // return v >= min && v <= max;
390 | // }
391 | //
392 | // export function setColorMatrix(colorMatrix: number[], hex: number) {
393 | // let result = Utils.hexToRGB(hex);
394 | // colorMatrix[0] = result.r / 255;
395 | // colorMatrix[6] = result.g / 255;
396 | // colorMatrix[12] = result.b / 255;
397 | // return colorMatrix;
398 | // }
399 | //
400 | // export function newColorMatrix(hex: number) {
401 | // let c = Utils.hexToRGB(hex);
402 | // return [
403 | // c.r / 255, 0, 0, 0, 0,
404 | // 0, c.g / 255, 0, 0, 0,
405 | // 0, 0, c.b / 255, 0, 0,
406 | // 0, 0, 0, 1, 0,
407 | // ];
408 | // }
409 | //
410 | // export function hexToRGB(hex: number) {
411 | // return {
412 | // b: hex & 0xff,
413 | // g: hex >> 8 & 0xff,
414 | // r: hex >> 16 & 0xff
415 | // }
416 | // }
417 | //
418 | // export function pad(num: number, n: number) {
419 | // return (Array(n).join("0") + num).slice(-n);
420 | // }
421 | //
422 | // export function arrayToSet(arr: T[]) {
423 | // let set: T[] = [];
424 | // for (let i = 0; i < arr.length; ++i) {
425 | // set.includes(arr[i]) || set.push(arr[i]);
426 | // }
427 | // return set;
428 | // }
429 | //
430 | // export function getMaxInArray(arr: number[]) {
431 | // let max = NaN;
432 | // for (let i = 0; i < arr.length; ++i) {
433 | // if (isNaN(max) || arr[i] > max) {
434 | // max = arr[i];
435 | // }
436 | // }
437 | // return max;
438 | // }
439 | //
440 | // // export function loadPrefab(url: string) {
441 | // // return new Promise(resolve => {
442 | // // cc.loader2.loadRes(url, cc.Asset, (e, res: cc.Prefab) => {
443 | // // resolve(res);
444 | // // });
445 | // // })
446 | // // }
447 | //
448 | // // export function getOrLoadPrefab(url: string) {
449 | // // return new Promise(resolve => {
450 | // // let ret = cc.loader2.getRes(url);
451 | // // if (ret) {
452 | // // resolve(ret);
453 | // // } else {
454 | // // cc.loader2.loadRes(url, cc.Asset, (e, res: cc.Prefab) => {
455 | // // resolve(res);
456 | // // });
457 | // // }
458 | // // })
459 | // // }
460 | //
461 | // // export function getOrLoadRes(url: string) {
462 | // // return new Promise(resolve => {
463 | // // let ret = cc.loader2.getRes(url);
464 | // // if (ret) {
465 | // // resolve(ret);
466 | // // } else {
467 | // // cc.loader2.loadRes(url, cc.Asset, (e, res) => {
468 | // // resolve(res);
469 | // // });
470 | // // }
471 | // // })
472 | // // }
473 | //
474 | // export function randomItemsFromArray(amount: number, arr: T[]) {
475 | // return makeArrayRandom(arr.concat()).slice(0, amount)
476 | // }
477 | //
478 | // export const deepClone = obj => JSON.parse(JSON.stringify(obj));
479 | //
480 | // export function wait(duration, callBack?) {
481 | // return new Promise((resolve, reject) => {
482 | // setTimeout(() => {
483 | // if (callBack) callBack();
484 | // resolve();
485 | // }, duration)
486 | // });
487 | // }
488 | //
489 | // export function callLater(callback: () => void, time = 0) {
490 | // setTimeout(callback, time)
491 | // }
492 | //
493 | // export function removeByValue(arr: any[], val: any) {
494 | // for (var i = 0; i < arr.length; i++) {
495 | // if (arr[i] == val) {
496 | // arr.splice(i, 1);
497 | // break;
498 | // }
499 | // }
500 | // }
501 | //
502 | // let _log = cc.log;
503 | // export function removeLog() {
504 | // if (Context.isFB) {
505 | // cc.log = () => { };
506 | // }
507 | // }
508 | // export function recoverLog() {
509 | // if (Context.isFB) {
510 | // cc.log = _log;
511 | // }
512 | // }
513 | //
514 | // export function formatHMS(v: number) {
515 | // if (v < 0) return;
516 | // let h = Math.floor(v / 3600) + "";
517 | // let m = Math.floor((v % 3600) / 60) + "";
518 | // let s = Math.floor(v % 60) + "";
519 | // return [h, m, s].map(str => str.length < 2 ? "0" + str : str).join(":");
520 | // }
521 | //
522 | // export function formatMS(v: number) {
523 | // if (v < 0) return;
524 | // let m = Math.floor((v % 3600) / 60) + "";
525 | // let s = Math.floor((v % 3600) % 60) + "";
526 | // return [m, s].map(str => str.length < 2 ? "0" + str : str).join(":");
527 | // }
528 | //
529 | // export function loadPrefab(url: string) {
530 | // return new Promise(resolve => {
531 | // cc.loader.loadRes(url, cc.Asset, (e, res: cc.Prefab) => {
532 | // resolve(res);
533 | // });
534 | // })
535 | // }
536 | //
537 | // // export function getOrLoadTexture(url: string, callback: (tex: cc.CCSampleWithAlphaSeparated) => void) {
538 | // // let tex = cc.loader2.getRes(url) as cc.CCSampleWithAlphaSeparated
539 | // // if (tex) {
540 | // // callback(tex);
541 | // // return;
542 | // // }
543 | // // cc.loader2.loadRes(url, cc.Asset, undefined, (e: Error, tex: cc.CCSampleWithAlphaSeparated) => {
544 | // // callback(tex);
545 | // // });
546 | // // }
547 | //
548 | // export function getRandomName() {
549 | // let arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
550 | // let ret: string[] = [];
551 | // for (let i = 0; i < 8; ++i) {
552 | // ret.push(randomInArr(arr));
553 | // }
554 | // return "Gardener_" + ret.join("");
555 | // }
556 | // }
557 |
--------------------------------------------------------------------------------
/assets/utils/utils.ts.meta:
--------------------------------------------------------------------------------
1 | {
2 | "ver": "4.0.23",
3 | "importer": "typescript",
4 | "imported": true,
5 | "uuid": "e423802c-af5f-49e9-9c7f-a641349fc72e",
6 | "files": [],
7 | "subMetas": {},
8 | "userData": {
9 | "simulateGlobals": []
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "NewProject",
3 | "type": "3d",
4 | "uuid": "c2e232f9-010c-4125-a4eb-c50bd821b252",
5 | "version": "3.6.0",
6 | "creator": {
7 | "version": "3.6.0"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/preview/flash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yansixing/cocos-shader-demo/2b7dca2ad14a560ae78c286591cb9e6a6cab9497/preview/flash.png
--------------------------------------------------------------------------------
/preview/gaussBlur.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yansixing/cocos-shader-demo/2b7dca2ad14a560ae78c286591cb9e6a6cab9497/preview/gaussBlur.png
--------------------------------------------------------------------------------
/preview/shadow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yansixing/cocos-shader-demo/2b7dca2ad14a560ae78c286591cb9e6a6cab9497/preview/shadow.png
--------------------------------------------------------------------------------
/preview/spriteOutline.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yansixing/cocos-shader-demo/2b7dca2ad14a560ae78c286591cb9e6a6cab9497/preview/spriteOutline.png
--------------------------------------------------------------------------------
/preview/waterRipple.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yansixing/cocos-shader-demo/2b7dca2ad14a560ae78c286591cb9e6a6cab9497/preview/waterRipple.gif
--------------------------------------------------------------------------------
/preview/waterWave.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yansixing/cocos-shader-demo/2b7dca2ad14a560ae78c286591cb9e6a6cab9497/preview/waterWave.gif
--------------------------------------------------------------------------------
/settings/v2/packages/builder.json:
--------------------------------------------------------------------------------
1 | {
2 | "__version__": "1.3.3"
3 | }
4 |
--------------------------------------------------------------------------------
/settings/v2/packages/cocos-service.json:
--------------------------------------------------------------------------------
1 | {
2 | "__version__": "3.0.4",
3 | "game": {
4 | "name": "未知游戏",
5 | "app_id": "UNKNOW",
6 | "c_id": "0"
7 | },
8 | "appConfigMaps": [
9 | {
10 | "app_id": "UNKNOW",
11 | "config_id": "334f76"
12 | }
13 | ],
14 | "configs": [
15 | {
16 | "app_id": "UNKNOW",
17 | "config_id": "334f76",
18 | "config_name": "Default",
19 | "config_remarks": "",
20 | "services": []
21 | }
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/settings/v2/packages/engine.json:
--------------------------------------------------------------------------------
1 | {
2 | "__version__": "1.0.6"
3 | }
4 |
--------------------------------------------------------------------------------
/settings/v2/packages/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "__version__": "1.0.2",
3 | "layer": [
4 | {
5 | "name": "default",
6 | "value": 1
7 | },
8 | {
9 | "name": "cut",
10 | "value": 2
11 | }
12 | ],
13 | "fbx": {
14 | "legacyFbxImporter": {
15 | "visible": true
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | /* Base configuration. Do not edit this field. */
3 | "extends": "./temp/tsconfig.cocos.json"
4 |
5 | /* Add your custom configuration here. */
6 | }
7 |
--------------------------------------------------------------------------------