blob: 93641ff3b8cb88d023fdb266e844d97d2434c619 [file] [log] [blame]
Brian Osman647c7a92019-10-07 09:38:30 -04001{
2 "MaxCount": 200,
3 "Drawable": {
4 "Type": "SkCircleDrawable",
5 "Radius": 8
6 },
7 "EffectCode": [
8 "void effectSpawn(inout Effect effect) {",
9 " effect.lifetime = 2;",
10 "}",
11 "",
12 "void effectUpdate(inout Effect effect) {",
13 " if (effect.age < 0.25 || effect.age > 0.75) { effect.rate = 0; }",
14 " else { effect.rate = 200; }",
15 "}",
16 ""
17 ],
18 "Code": [
19 "void spawn(inout Particle p) {",
20 " float3 colors[4];",
21 " colors[0] = float3(0.87, 0.24, 0.11);",
22 " colors[1] = float3(1, 0.9, 0.2);",
23 " colors[2] = float3(0.44, 0.73, 0.24);",
24 " colors[3] = float3(0.38, 0.54, 0.95);",
Brian Osman95c26ef2020-02-10 13:45:22 -050025 " int idx = int(rand(p.seed) * 4);",
Brian Osman647c7a92019-10-07 09:38:30 -040026 " p.color.rgb = colors[idx];",
27 "",
28 " p.lifetime = (1 - effect.age) * effect.lifetime;",
Brian Osman95c26ef2020-02-10 13:45:22 -050029 " p.scale = mix(0.6, 1, rand(p.seed));",
Brian Osman647c7a92019-10-07 09:38:30 -040030 "}",
31 "",
32 "void update(inout Particle p) {",
33 " p.color.a = 1 - p.age;",
34 "",
Brian Osman95c26ef2020-02-10 13:45:22 -050035 " float a = radians(rand(p.seed) * 360);",
Brian Osman647c7a92019-10-07 09:38:30 -040036 " float invAge = 1 - p.age;",
Brian Osman95c26ef2020-02-10 13:45:22 -050037 " p.vel = float2(cos(a), sin(a)) * mix(250, 550, rand(p.seed)) * invAge * invAge;",
Brian Osman647c7a92019-10-07 09:38:30 -040038 "}",
39 ""
40 ],
41 "Bindings": []
42}