• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1{
2   "MaxCount": 2000,
3   "Drawable": {
4      "Type": "SkCircleDrawable",
5      "Radius": 4
6   },
7   "Code": [
8      "void effectSpawn(inout Effect effect) {",
9      "  effect.lifetime = 2;",
10      "  effect.rate = 200;",
11      "}",
12      "",
13      "void spawn(inout Particle p) {",
14      "  p.lifetime = 10;",
15      "}",
16      "",
17      "float4x4 rx(float rad) {",
18      "  float c = cos(rad);",
19      "  float s = sin(rad);",
20      "  return float4x4(1, 0,  0, 0,",
21      "                  0, c, -s, 0,",
22      "                  0, s,  c, 0,",
23      "                  0, 0,  0, 1);",
24      "}",
25      "",
26      "float4x4 ry(float rad) {",
27      "  float c = cos(rad);",
28      "  float s = sin(rad);",
29      "  return float4x4(c, 0, -s, 0,",
30      "                  0, 1,  0, 0,",
31      "                  s, 0,  c, 0,",
32      "                  0, 0,  0, 1);",
33      "}",
34      "",
35      "float4x4 rz(float rad) {",
36      "  float c = cos(rad);",
37      "  float s = sin(rad);",
38      "  return float4x4( c, s, 0, 0,",
39      "                  -s, c, 0, 0,",
40      "                   0, 0, 1, 0,",
41      "                   0, 0, 0, 1);",
42      "}",
43      "",
44      "void update(inout Particle p) {",
45      "  float3 pos = float3(rand(p.seed), rand(p.seed), rand(p.seed));",
46      "  if (rand(p.seed) < 0.33) {",
47      "    if (pos.x > 0.5) {",
48      "      pos.x = 1;",
49      "      p.color.rgb = float3(1, 0.2, 0.2);",
50      "    } else {",
51      "      pos.x = 0;",
52      "      p.color.rgb = float3(0.2, 1, 1);",
53      "    }",
54      "  } else if (rand(p.seed) < 0.5) {",
55      "    if (pos.y > 0.5) {",
56      "      pos.y = 1;",
57      "      p.color.rgb = float3(0.2, 0.2, 1);",
58      "    } else {",
59      "      pos.y = 0;",
60      "      p.color.rgb = float3(1, 1, 0.2);",
61      "    }",
62      "  } else {",
63      "    if (pos.z > 0.5) {",
64      "      pos.z = 1;",
65      "      p.color.rgb = float3(0.2, 1, 0.2);",
66      "    } else {",
67      "      pos.z = 0;",
68      "      p.color.rgb = float3(1, 0.2, 1);",
69      "    }",
70      "  }",
71      "",
72      "  float s = effect.age * 2 - 1;",
73      "  s = s < 0 ? -s : s;",
74      "",
75      "  pos = pos * 2 - 1;",
76      "  pos = mix(pos, normalize(pos), s);",
77      "  pos = pos * 100;",
78      "",
79      "  float age = float(effect.loop) + effect.age;",
80      "  float4x4 mat = rx(age * radians(60))",
81      "               * ry(age * radians(70))",
82      "               * rz(age * radians(80));",
83      "  pos = (mat * float4(pos, 1)).xyz;",
84      "",
85      "  p.pos.x = pos.x;",
86      "  p.pos.y = pos.y;",
87      "  p.scale = ((pos.z + 50) / 100 + 0.5) / 2;",
88      "}",
89      ""
90   ],
91   "Bindings": []
92}